PHP¿ë ADOdb ¶óÀ̺귯¸®

V4.04 13 Nov 2003 (c) 2000-2003 John Lim (jlim#natsoft.com)

º¯¿ª: Jae-Geun Kim/DoA (artech@qaos.com)

ÀÌ ¼ÒÇÁÆ®¿þ¾î´Â BSD Çü½Ä°ú LGPL Çü½ÄÀÇ µÎ°¡Áö ¶óÀ̼¾½º¸¦ »ç¿ëÇÑ´Ù. ÀÌ °ÍÀº ÀÌ ¼ÒÇÁÆ®¿þ¾î¸¦ ÄÄÆÄÀÏÇؼ­ »ó¾÷ÀûÀÎ Á¦Ç°¿¡ »ç¿ëÇÒ ¼ö ÀÖ´Ù´Â °ÍÀ» ÀǹÌÇÑ´Ù.

À¯¿ëÇÑ ADOdb ¸µÅ©: ´Ù¿î·Îµå   ´Ù¸¥ ¹®¼­

¼Ò°³
Ư¡
ADOdb¸¦ »ç¿ëÇÏ´Â »çÀÌÆ®
¼öÁ¤ ¹× ¹ö±× º¸°í
¼³Ä¡
ÃÖ¼Ò ¼³Ä¡
ÄÚµå ÃʱâÈ­¿Í Á¢¼Ó ¿¹
°í¼Ó ADOdb

¾ÈÀüÇÏ°Ô ADOdb º¯°æÇϱâ
ADONewConnection NewADOConnection
PHP5 Ư¡
foreach ·çÇÁ ¿¹¿Üó¸®
Áö¿øµÇ´Â DB
±æÀâÀÌ
¿¹ 1: Select
¿¹ 2: °í±Þ Select
¿¹ 3: Insert
¿¹ 4: µð¹ö±ë  rs2html ¿¹
¿¹ 5: MySQL°ú ¸Þ´º
¿¹ 6: ¿©·¯ DB¿¡ µ¿½Ã Á¢¼ÓÇϱâ
¿¹ 7: Update, Insert SQL »ý¼ºÇϱâ
¿¹ 8: ÀÌÀü, ÀÌÈÄ ÆäÀÌÁö·Î À̵¿Çϱâ
¿¹ 9: CSV ¶Ç´Â ÅǺи® Çü½ÄÀ¸·Î ³»º¸³»±â
¿¹ 10: »ç¿ëÀÚ ÇÊÅÍ
¿¹ 11: Áö´ÉÀû Æ®·£Àè¼Ç

»ç¿ëÀÚ ¿À·ù ó¸®¿Í PEAR_Error »ç¿ëÇϱâ
µ¥ÀÌŸ ¼Ò½º¸í(DSN)
ij½³
ÇÇÆá Å×À̺í

ÂüÁ¶

º¯¼ö: $ADODB_COUNTRECS $ADODB_ANSI_PADDING_OFF $ADODB_CACHE_DIR $ADODB_FETCH_MODE $ADODB_LANG
»ó¼ö:
ADODB_ASSOC_CASE
ADOConnection
¿¬°á: Connect PConnect NConnect
SQL ½ÇÇà: Execute CacheExecute SelectLimit CacheSelectLimit Param Prepare PrepareSP Parameter
              GetOne CacheGetOne GetRow CacheGetRow GetAll CacheGetAll GetCol CacheGetCol GetAssoc CacheGetAssoc Replace
               ExecuteCursor (oci8 ¸¸)
SQL ¹®Àå »ý¼º: GetUpdateSQL GetInsertSQL Concat IfNull substr random qstr Param OffsetDate SQLDate DBDate DBTimeStamp
ºê·Ó(Blobs): UpdateBlob UpdateClob UpdateBlobFile BlobEncode BlobDecode
ÆäÀÌÁö À̵¿: PageExecute CachePageExecute
Áö¿ì±â: CacheFlush Close
Æ®·¢Àè¼Ç: StartTrans CompleteTrans FailTrans HasFailedTrans BeginTrans CommitTrans RollbackTrans
µ¥ÀÌŸ °¡Á®¿À±â:
SetFetchMode
¹®ÀÚ¿­ ó¸®: concat qstr quote substr
³¯Â¥: DBDate DBTimeStamp UnixDate UnixTimeStamp OffsetDate SQLDate
Çà°ü¸®: Affected_Rows Insert_ID RowLock GenID CreateSequence DropSequence
¿À·ù ó¸®: ErrorMsg ErrorNo MetaError MetaErrorMsg
µ¥ÀÌŸ »çÀü(¸ÞŸµ¥ÀÌŸ): MetaDatabases MetaTables MetaColumns MetaColumnNames MetaPrimaryKeys MetaForeignKeys ServerInfo
Åë°è ¹× Äõ¸® Àç»ý¼º: LogSQL fnExecute and fnCacheExecute
Deprecated: Bind BlankRecordSet

ADORecordSet

ÇÑ ÇÊµå ¸®ÅÏ: Fields
ÇÑ Çà ¸®ÅÏ:FetchRow FetchInto FetchObject FetchNextObject FetchObj FetchNextObj GetRowAssoc
¸ðµç Çà ¸®ÅÏ:GetArray GetRows GetAssoc
À̵¿:Move MoveNext MoveFirst MoveLast AbsolutePosition CurrentRow AtFirstPage AtLastPage AbsolutePage

¸Þ´º »ý¼º:GetMenu GetMenu2
³¯Â¥:UserDate UserTimeStamp UnixDate UnixTimeStamp
·¹ÄÚµå¼Â Á¤º¸:RecordCount PO_RecordSet NextRecordSet
Çʵå Á¤º¸:FieldCount FetchField MetaType
»èÁ¦: Close

rs2html  ¿¹
ADOdb¿Í ADOÀÇ Â÷ÀÌ
DB µå¶óÀ̹ö ±æÀâÀÌ
º¯°æ»çÇ×

¼Ò°³

PHP´Â Ç¥ÁØÈ­µÈ DB Á¢±ÙÇÔ¼ö¸¦ °¡Áö°íÀÖÁö¾Ê´Ù. ADOdb´Â ¼­·Î ´Ù¸¥ DB API »çÀÌÆ® Â÷À̸¦ ¼û±æ ¼ö ÀÖ´Â DB Å©·¡½º(Â÷ÀÌÁ¡Àº ĸ½¶È­µÈ´Ù), µû¶ó¼­ µ¥ÀÌŸº£À̽º¸¦ ½±°Ô ¹Ù²Ü ¼ö ÀÖ´Â DB Å©·¡½º¿¡´ëÇÑ Çʿ伺¶§¹®¿¡ ¸¸µé¾îÁ³´Ù. ADOdb´Â PHP 4.0.5 ÀÌ»óÀÇ ¹öÀüÀ» ÇÊ¿ä·Î ÇÑ´Ù(¹è¿­À» ó¸®ÇÒ ¼ö ÀÖ´Â str_replace¸¦ »ç¿ëÇϱ⶧¹®ÀÌ´Ù).

MySQL, Oracle, Microsoft SQL Server, Sybase, Sybase SQL Anywhere, Informix, PostgreSQL, FrontBase, SQLite, Interbase(Firebird¿Í Borland º¯Á¾), Foxpro, Access, ADO, DB2, SAP DB¿Í ODBC¸¦ Áö¿øÇÑ´Ù. ¶ÇÇÑ ODBC¸¦ ÅëÇØ Progress¿Í CacheLite¿¡ ¼º°øÀûÀ¸·Î Á¢¼ÓÇß´Ù´Â º¸°í¸¦ ¹Þ¾Ò´Ù. ¿ì¸®´Â º¸´Ù ¸¹Àº »ç¶÷µéÀÌ ¿©·¯ µ¥ÀÌŸº£À̽º¸¦ Áö¿øÇÏ´Â µå¶óÀ̹ö °³¹ß¿¡ ±â¿©Çϱâ¹Ù¶õ´Ù.

PHP4´Â ¼¼¼Ç º¯¼ö¸¦ Áö¿øÇÑ´Ù. ȣȯ¼º°ú È®À强À» À§ÇØ ¼¼¼Ç Á¤º¸¸¦ ADOdb¸¦ »ç¿ëÇؼ­ ÀúÀåÇÒ ¼ö ÀÖ´Ù. º¸´Ù ÀÚ¼¼ÇÑ Á¤º¸´Â adodb-session.php¸¦ º¸±â¹Ù¶õ´Ù.

´Ù¸¥ DB¿Í ȣȯµÇ´Â SQL ¾²±âÀ§ÇÑ ÆÁÀº http://php.weblogs.com/portable_sql(¶ÇÇÑ ÀÌ ¹èÆ÷º»ÀÇ tips_portable_sql.htm¸¦ »ç¿ëÇÒ ¼ö ÀÖ´Ù)À» º¸±â¹Ù¶õ´Ù.

ADOdbÀÇ Æ¯Â¡

ADOdb¸¦ »ç¿ëÇÏ´Â »çÀÌÆ®

´ÙÀ½Àº ADOdb¸¦ »ç¿ëÇؼ­ ±¸ÃàµÈ »çÀÌÆ®ÀÌ´Ù(º¸´Ù ¸¹Àº »çÀÌÆ®´Â http://php.weblogs.com/adodb-cool-applications¸¦ ¹æ¹®Çϱ⠹ٶõ´Ù):

¼öÁ¤ ¹× ¹ö±× º¸°í

¼öÁ¤ ¹× ¹ö±× º¸°í´Â jlim#natsoft.com.my·Î ÀüÀÚ¿ìÆíÀ» º¸³»°Å³ª ADOdb Æ÷·³(http://phplens.com/lens/lensforum/topics.php?id=4)¿¡ ¿Ã¸®±â ¹Ù¶õ´Ù.

¼³Ä¡ ±æÀâÀÌ

PHP 4.0.4 ÀÌ»óÀÇ ¹öÀüÀ» »ç¿ëÇÏ´ÂÁö È®½ÇÈ÷Çϱ⠹ٶõ´Ù. À¥¼­¹ö°¡ Á¢±ÙÇÒ ¼ö ÀÖ´Â µð·ºÅ丮¿¡ ¸ðµç ÆÄÀÏÀ» ¾ÐÃàÇØÁ¦ÇÑ´Ù.

Á¤»óÀûÀÎ ¼³Ä¡¿©ºÎ¸¦ °Ë»çÇϱâÀ§ÇØ ±æÀâÀÌÀÇ ¿¹¸¦ º¯°æÇÑ´Ù. Á¢¼Ó ¼³Á¤ÀÌ ¿Ã¹Ù¸¥Áö È®½ÇÈ÷ ÇÑ´Ù. ´ÙÀ½ ¿¹¿¡ º¸¿©Áø °Íó·³ $db->debug = true¸¦ ¼³Á¤ÇÔÀ¸·Î¼­ µð¹ö±×ÇÒ ¼ö ÀÖ´Ù:

<?php
	include('adodb/adodb.inc.php');
	$db = ADONewConnection($dbdriver); # ¿¹ 'mysql' ¶Ç´Â 'postgres'
	$db->debug = true;
	$db->Connect($server, $user, $password, $database);
	$rs = $db->Execute('select * from some_small_table');
	print "<pre>";
	print_r($rs->GetRows());
	print "</pre>";
?>

ÃÖ¼Ò ¼³Ä¡

ADOdb¸¦ ÇÊ¿äÇÑ ÆÄÀϸ¸ ¼³Ä¡ÇÏ·Á´Â °³¹ßÀÚÀÇ °æ¿ì ´ÙÀ½ ÆÄÀϸ¸ ¼³Ä¡ÇϸéµÈ´Ù:

ÄÚµå ÃʱâÈ­ ¿¹

ADOdb¸¦ ±âµ¿ÇÒ ¶§ Àû¾îµµ µÎ°³ÀÇ ÆÄÀÏÀÌ ¸ÕÀú ÀÐÇôÁ®¾ß ÇÑ´Ù. ù¹ø°´Â adodb/adodb.inc.php·Î¼­ ¸ðµç DB Å©·¡½º¿¡ÀÇÇØ »ç¿ëµÇ´Â ÇÔ¼ö°¡ Æ÷ÇԵǾî ÀÖ´Ù. ƯÁ¤ DB¿¡´ëÇØ Á¤ÀÇµÈ ÄÚµå´Â adodb/driver/adodb-????.inc.php ÆÄÀÏ¿¡ Æ÷ÇԵǾî ÀÖ´Ù.

¿¹¸¦µé¾î, mysql µ¥ÀÌŸº£¿¡½º¿¡ Á¢¼ÓÇÏ·Á¸é ´ÙÀ½°ú °°Àº Äڵ带 »ç¿ëÇÑ´Ù:

include('/path/to/set/here/adodb.inc.php');
$conn = &ADONewConnection('mysql');

DB Á¢¼ÓÀÌ ÇÊ¿äÇÑ °æ¿ì Ç×»ó ADONewConnection($driver) ÇÔ¼ö¸¦ »ç¿ëÇؼ­ Á¢¼Ó °³Ã¼¸¦ »ý¼ºÇÑ´Ù. NewADOConnection($driver)´Â º°¸íÀÌ´Ù.

ÀÌ ½ÃÁ¡¿¡¼­ DB¿¡ Á¢¼ÓµÇ´Â °ÍÀº ¾Æ´Ï´Ù. Á¢¼ÓÇϱâÀü¿¡ ¿µ±¸ Á¢¼ÓÀ» ÇÒ °ÍÀÎÁö ÀϽà Á¢¼ÓÀ» ÇÒ °ÍÀÎÁö °áÁ¤ÇؾßÇÑ´Ù. ¿µ±¸ Á¢¼ÓÀÇ ÀÕÁ¡Àº DB Á¢¼ÓÀÌ ²÷¾îÁöÁö¾ÊÀ¸¹Ç·Î ºü¸£´Ù´Â °ÍÀÌ´Ù(½ÉÁö¾î Close()¸¦ È£ÃâÇصµ). ÀϽà Á¢¼ÓÀº ÈξÀ ÀûÀº ½Ã½ºÅÛ ÀÚ¿øÀ» ÀÚÄ¡ÇϹǷΠDB ¼­¹ö³ª À¥ ¼­¹ö¿¡ °úºÎÇÏ°¡ °É¸± À§Ç輺À» ÁÙÀÏ ¼ö ÀÖ´Ù.

¿µ±¸ Á¢¼ÓÀÇ °æ¿ì, $conn->PConnect()¸¦ »ç¿ëÇϸç, ÀϽà Á¢¼ÓÀÇ °æ¿ì $conn->Connect()¸¦ »ç¿ëÇÑ´Ù. ¸î¸î DB µå¶óÀ̹ö´Â NConnect()¸¦ Áö¿øÇÑ´Ù. NConnect()´Â °­Á¦·Î »õ·Î¿î Á¢¼ÓÀ» »ý¼ºÇÑ´Ù.

Á¢¼Ó½Ã ÁÖÀÇ»çÇ×: µÎ°³ÀÇ Á¢¼ÓÀ» »ý¼ºÇϸ鼭 µ¿ÀÏÇÑ »ç¿ëÀÚ ID¿Í PW¸¦ »ç¿ëÇϸé PHP´Â Á¢¼ÓÀ» °øÀ¯ÇϰԵȴÙ. ÀÌ °æ¿ì »õ·Î »ý¼ºµÈ Á¢¼ÓÀÌ ´Ù¸¥ DB¿¡ Á¢¼ÓÇÏ´Â °ÍÀ̶ó¸é ¹®Á¦¸¦ ¹ß»ýÇÒ ¼ö ÀÖ´Ù. ÀÌ ¹®Á¦¸¦ ÇØ°áÇÏ´Â ¹æ¹ýÀº ¼­·Î ´Ù¸¥ µ¥ÀÌŸº£À̽º¿¡ ¿¬°áÇÏ´Â °æ¿ì Ç×»ó ´Ù¸¥ »ç¿ëÀÚ ID¸¦ »ç¿ëÇϰųª NConnect()¸¦ »ç¿ëÇÏ´Â °ÍÀÌ´Ù.

DB Á¢¼Ó ¿¹

MySQL°ú ÀÚÁÖ »ç¿ëµÇ´Â DB µå¶óÀ̹ö

MySQL Á¢¼ÓÀº ¾ÆÁÖ Á÷°üÀûÀÌ´Ù. ¸ðµç ¸Å°³º¯¼ö´Â mysql_connect¿Í µ¿ÀÏÇÏ´Ù:

	$conn = &ADONewConnection('mysql'); 
	$conn->PConnect('localhost','userid','password','database');
 

´ëºÎºÐÀÇ ´Ù¸¥ DB µå¶óÀ̹öµµ ºñ½ÁÇÑ ±ÔÄ¢À» »ç¿ëÇÑ´Ù:

Connect($server, $user, $password, $database)

¿¹¿Ü´Â ´ÙÀ½¿¡ ¿­°ÅµÇ¾ú´Ù.

PostgreSQL

PostgreSQL¿¡¼­ Çã¿ëµÇ´Â ¿¬°á:

a. Ç¥ÁØ Á¢¼Ó ¹®ÀÚ¿­:

	$conn = &ADONewConnection('postgres7'); 
	$conn->PConnect('host=localhost port=5432 dbname=mary');

b. ÀüÅëÀûÀÎ 4°³ÀÇ ¸Å°³º¯¼ö »ç¿ë:

	$conn->PConnect('localhost','userid','password','database');
 

Interbase/Firebird

$host ¸Å°³º¯¼ö¿¡ µ¥ÀÌŸº£À̽º¸¦ Á¤ÀÇÇÑ´Ù:
	$conn = &ADONewConnection('ibase'); 
	$conn->PConnect('localhost:c:\ibase\employee.gdb','sysdba','masterkey');

Oracle

OracleÀÇ °æ¿ì ¿©·¯°¡Áö ¹æ¹ýÀ¸·Î ¿¬°áÇÒ ¼ö ÀÖ´Ù.

a. PHP¿Í OracleÀÌ µ¿ÀÏÇÑ ÄÄÇ»ÅÍ¿¡ ¼³Ä¡µÈ °æ¿ì, ±âº» SID »ç¿ë.

	$conn->Connect(false, 'scott', 'tiger');

b. TNS ¸íÀÌ Á¤ÀÇµÈ °æ¿ì, ¿¹. 'myTNS'

	$conn->PConnect(false, 'scott', 'tiger', 'myTNS');

¶Ç´Â

 	$conn->PConnect('myTNS', 'scott', 'tiger');

c. È£½ºÆ® ÁÖ¼Ò¿Í SID

	$conn->Connect('192.168.0.1', 'scott', 'tiger', 'SID');

d. È£½ºÆ® ÁÖ¼Ò¿Í ¼­ºñ½º ¸í

	$conn->Connect('192.168.0.1', 'scott', 'tiger', 'servicename');

ODBC·Î DSN¾øÀÌ ¿¬°áÇϱâ(Access¿Í mssql ¿¹)

ODBC´Â ODBC Á¦¾îÆÇÀ¸·Î DSNÀ» »ý¼ºÇϰųª DSNÀÌ ¾øÀÌ ¿¬°áÇÒ ¼ö ÀÖ´Ù.ODBC·Î DSNÀÌ ¾øÀÌ ¿¬°áÇÏ·Á¸é PHP 4.3 ÀÌ»óÀ» ÇÊ¿ä·Î ÇÑ´Ù.

Microsoft Access:

	$db =& ADONewConnection('access');
	$dsn = "Driver={Microsoft Access Driver (*.mdb)};Dbq=d:\northwind.mdb;Uid=Admin;Pwd=;";
	$db->Connect($dsn);
Microsoft SQL Server:
	$db =& ADONewConnection('odbc_mssql');
	$dsn = "Driver={SQL Server};Server=localhost;Database=northwind;";
	$db->Connect($dsn,'userid','password');
ADO·Î DSNÀÌ ¾øÀÌ ¿¬°áÇϱâ
¸¸¾à PHP 4.3.0 ÀÌÇÏÀÇ ¹öÀüÀ» »ç¿ëÇϸ鼭 DSNÀÌ ¾øÀÌ ¿¬°áÇÏ·Á¸é MicrosoftÀÇ ADO(MicrosoftÀÇ COM API)°¡ ÀÖ¾î¾ßÇÑ´Ù. ADOdb ¶óÀ̺귯¸®¿Í MicrosoftÀÇ ADO¸¦ »ç¿ëÇÑ ¿¹:
<?php
	include('adodb.inc.php'); 
	ADOLoadCode("ado_mssql");
	$db = &ADONewConnection("ado_mssql");
	print "<h1>DSNÀÌ ¾ø´Â DB ¿¬°á: $db->databaseType...</h1>";
		
	$myDSN="PROVIDER=MSDASQL;DRIVER={SQL Server};"
		. "SERVER=flipper;DATABASE=ai;UID=sa;PWD=;"  ;
	$db->Connect($myDSN);
	
	$rs = $db->Execute("select * from table");
	$arr = $rs->GetArray();
	print_r($arr);
?>

°í¼Ó ADOdb

ADOdb´Â ´ëÇü Å©·¡½º ÀÌÁö¸¸ ´Ù¸¥ ¸ðµç PHP Å©·¡½º¿¡¹èÇØ ¼º´É»ó ÀÏ°üµÈ ¿ìÀ§¸¦ º¸¿©¿Ô´Ù. ÀÌ °ÍÀº Onion°ú °°Àº °èÃþÈ­ ÆмÇ(ÇÙ½É ·¹ÀÌ¿©¿¡¼­ °¡Àå ºü¸¥ ÇÔ¼ö)À¸·Î ¼³°èµÇ¾ú±â ¶§¹®ÀÌ´Ù. ÃÖÀûÀÇ ¼º´ÉÀ» À§ÇØ ´ÙÀ½ ÇÔ¼ö¸¦ °í¼öÇϱâ¹Ù¶õ´Ù.:

ÇÙ½É ·¹ÀÌ¿©

Connect, PConnect, NConnect
Execute, CacheExecute
SelectLimit, SelectLimit
MoveNext, Close

Çʵ忡 Á¢±ÙÇÏ´Â °¡Àå ºü¸¥ ¹æ¹ýÀº ¹è¿­, $recordset->fields¸¦ Á÷Á¢ Á¢±ÙÇÏ´Â °ÍÀÌ´Ù. ¶ÇÇÑ µ¥ÀÌŸº£À̽º¿¡ ¿¬°áÇϱâÀü¿¡ Àü¿ª º¯¼ö, $ADODB_FETCH_MODE = ADODB_FETCH_NUM¿Í $ADODB_COUNTRECS = false¸¦ ¼³Á¤ÇÒ ¼ö ÀÖ´Ù.

µ¥ÀÌŸº£À̽º°¡ ¹ÙÀεùÀ» Áö¿øÇÑ´Ù¸é ¹ÙÀεùÀ» »ç¿ëÇϱ⠹ٶõ´Ù. ¹ÙÀεùÀº Äõ¸®¸¦ ´Ù½Ã »ç¿ëÇÒ ¶§ ¼º´ÉÀÌ °³¼±µÈ´Ù. º´¸ñ Çö»óÀ» ÆÇÁ¤ÇϱâÀ§ÇØ ADOdbÀÇ ¼º´É Æ©´× ½Ã½ºÅÛÀ» »ç¿ëÇϱ⠹ٶõ´Ù.

¸¶Áö¸·À¸·Î APC, Turck MMCache, Zend Accelerator³ª ionCube¿Í°°Àº PHP °¡¼Ó±â°¡ ¼³Ä¡µÇ¾î ÀÖ´ÂÁö È®½ÇÈ÷Çϱ⠹ٶõ´Ù.

¾ÈÀüÇÏ°Ô ADOdb º¯°æÇϱâ

ÇÊ¿äÇÑ °æ¿ì ADOdb¸¦ º¯°æÇÒ ¼ö ÀÖ´Ù. ´ÙÇàÈ÷ ADOdb¸¦ ÇÏÀ§ Å©·¡½º·Î ¸¸µé°í $ADODB_NEWCONNECTION º¯¼ö¸¦ »ç¿ëÇÔÀ¸·Î¼­ ¿ªÈ£È¯¼ºÀ» À¯ÁöÇÒ ¼ö ÀÖ´Ù. $ADODB_NEWCONNECTIONÀ¸·Î ADONewConnection()ÀÇ µ¿ÀÛÀ» Á¦¾îÇÒ ¼ö ÀÖ´Ù. ADONewConnection()Àº ÀÌ º¯¼ö¸¦ °Ë»çÇÏ°í ÀÌ º¯¼ö°¡ Á¤ÀÇµÈ °æ¿ì ÀÌ º¯¼ö¿¡¼­ Áö½ÃÇÏ´Â ÇÔ¼ö¸¦ È£ÃâÇÑ´Ù.

´ÙÀ½ ¿¹´Â Á¢¼Ó °³Ã¼¸¦ »ý¼ºÇÏ´Â »õ·Î¿î ÇÔ¼ö, hack_mysql°ú hack_postgres7¸¦ ¸¸µå´Â ¿¹ÀÌ´Ù. ·¹ÄÚµå¼Â °³Ã¼ À̸§À» ºÎ¿©ÇÏ´Â ±ÔÄ¢Àº $rsPrefix¸¦ »ç¿ëÇؼ­ Á¦¾îÇÒ ¼ö ÀÖ´Ù. ÀÌ ¿¹¿¡¼­´Â 'hack_rs_'¸¦ »ç¿ëÇÏ°í ÀÖÀ¸¸ç, ÀÌ·ÎÀÎÇØ ADOdb´Â ·¹ÄÚµå¼Â °³Ã¼·Î¼­ hack_rs_mysql¿Í hack_rs_postgres7¸¦ »ç¿ëÇÒ ¼ö ÀÖ´Ù. ¸¸¾à ±âº» ADOdb µå¶óÀ̹ö¸¦ ¿øÇÑ´Ù¸é °ÅÁþÀ» ¸®ÅÏÇÏ¸é µÈ´Ù.

class hack_mysql extends adodb_mysql {
var $rsPrefix = 'hack_rs_';
  /* ÀڽŸ¸ÀÇ ±â´É */
}

class hack_rs_mysql extends ADORecordSet_mysql {
 /* ÀڽŸ¸ÀÇ ±â´É */
}

class hack_postgres7 extends adodb_postgres7 {
var $rsPrefix = 'hack_rs_';
  /* ÀڽŸ¸ÀÇ ±â´É */
}

class hack_rs_postgres7 extends ADORecordSet_postgres7 {
 /* ÀڽŸ¸ÀÇ ±â´É */
}

$ADODB_NEWCONNECTION = 'hack_factory';

function& hack_factory($driver)
{
	if ($driver !== 'mysql' && $driver !== 'postgres7') return false;
	
	$driver = 'hack_'.$driver;
	$obj = new $driver();
	return $obj;
}

include_once('adodb.inc.php');

ºÎ¸ð Å©·¡½ºÀÇ »ý¼ºÀÚ¸¦ ¹Ýµå½Ã È£ÃâÇØ¾ß ÇÑ´Ù.

PHP5 Ư¡

ADOdb 4.02 ÀÌ»óÀº »ç¿ëÇÏ°í ÀÖ´Â PHP ¹öÀüÀÌ ¹«¾úÀÎÁö ºÐ¸íÇÏ°Ô °áÁ¤ÇÒ ¼ö ÀÖ´Ù. ¸¸¾à PHP5°¡ °ËÃâµÇ¸é ´ÙÀ½ Ư¡À» »ç¿ëÇÒ ¼ö ÀÖ´Ù:

Áö¿øµÇ´Â DB

À̸§ °Ë»ç DB RecordCount() Áö¿ø ÀüÁ¦Á¶°Ç ¿î¿µÃ¼°è
access B Microsoft Access/Jet. ODBC DSNÀ» »ý¼º. Y/N ODBC Windows ¸¸
ado B

ÀÏ¹Ý ADO(ƯÁ¤ DB·Î Æ©´×µÇÁö ¾ÊÀº ADO). DSN ¾øÀÌ ¿¬°á °¡´É. ÃÖÀûÀÇ ¼º´ÉÀÌ ÇÊ¿äÇÑ °æ¿ì OLEDB¸¦ »ç¿ë. ÀÌ °ÍÀº ¸ðµç ADO µå¶óÀ̹öÀÇ ±âº» Å©·¡½ºÀÓ.

¿¬°áÀü $db->codePage¸¦ ¼³Á¤ÇÒ ¼ö ÀÖÀ½.

?´Â DB¿¡ ÀÇÁ¸ ADO ¶Ç´Â OLEDB Windows ¸¸
ado_access B ADO¸¦ »ç¿ëÇÑ Microsoft Access/Jet. DSN ¾øÀÌ ¿¬°á °¡´É. ÃÖÀûÀÇ ¼º´ÉÀÌ ÇÊ¿äÇÑ °æ¿ì OLEDB¸¦ »ç¿ë. Y/N ADO ¶Ç´Â OLEDB Windows ¸¸
ado_mssql B ADO¸¦ »ç¿ëÇÑ Microsoft SQL Server. DSN ¾øÀÌ ¿¬°á °¡´É. ÃÖÀûÀÇ ¼º´ÉÀÌ ÇÊ¿äÇÑ °æ¿ì OLEDB¸¦ »ç¿ë. Y/N ADO ¶Ç´Â OLEDB Windows ¸¸
db2 A DB2. ½Å·Ú¼ºÀÖ´Â µ¿ÀÛÀº ODBC µå¶óÀ̹ö¸¦ »ç¿ëÇØ¾ß ÇÔ. Y/N DB2 CLI/ODBC ÀÎÅÍÆäÀ̽º

Unix¿Í Windows. Unix ¼³Ä¡ ÈùÆ®.

vfp A Microsoft Visual FoxPro. ODBC DSNÀ» »ý¼ºÇØ¾ß ÇÔ. Y/N ODBC Windows ¸¸
fbsql C FrontBase. Y ?

Unix¿Í Windows

ibase B Interbase 6 ¶Ç´Â ±× ÀÌÇÏ. ¸î¸î »ç¿ëÀÚÀÇ º¸°í¿¡ µû¸£¸é
$db->PConnect('localhost:c:/ibase/employee.gdb', "sysdba", "masterkey")¸¦ »ç¿ëÇؼ­ ¿¬°áÇØ¾ß ÇÔ. ÇöÀç Affected_Rows¸¦ Áö¿øÇÏÁö ¾ÊÀ½.

¿¬°á Àü¿¡ $db->dialect, $db->buffers¿Í $db->charSet ¼³Á¤ÇÒ ¼ö ÀÖÀ½.
Y/N Interbase Ŭ¶óÀ̾ðÆ® Unix¿Í Windows
firebird C InterbaseÀÇ Firebird ¹öÀü. Y/N Interbase Ŭ¶óÀ̾ðÆ® Unix¿Í Windows
borland_ibase C Interbase 6.5 ÀÌ»óÀÇ Borland ¹öÀü. Æ÷Å©ÇÏ´Â ¹æ¹ýÀÌ ´Ù¸§. Y/N Interbase Ŭ¶óÀ̾ðÆ® Unix¿Í Windows
informix72 C SELECT FIRST¸¦ Áö¿øÇÏÁö ¾Ê´Â Informix 7.3ÀÌÀü ¹öÀüÀÇ Informix. Y/N Informix Ŭ¶óÀ̾ðÆ® Unix¿Í Windows
informix C ÀÏ¹Ý informix µå¶óÀ̹ö. Y/N Informix Ŭ¶óÀ̾ðÆ® Unix¿Í Windows
mssql A

Microsoft SQL Server 7 ÀÌ»ó. Microsoft SQL Server 2000 ¶ÇÇÑ Àß µ¿ÀÛÇÔ. ÁÖÀÇ: ÀÌ µå¶óÀ̹ö´Â ³¯Â¥ º¯È¯¿¡ ¹®Á¦°¡ ÀÖÀ½. ¿¹: PHP mssql È®Àå ¸ðµâÀº datetime¿¡¼­ ½Ã°£À» ¸®ÅÏÇÏÁö ¾ÊÀ½.

Y/N Mssql Ŭ¶óÀ̾ðÆ®

Unix¿Í Windows.
Unix ¼³Ä¡ ±æÀâÀÌ¿Í ´Ù¸¥ °Í.

mssqlpo A

ȣȯ¼ºÀÖ´Â msssql µå¶óÀ̹ö. À§ÀÇ mssql µå¶óÀ̹ö¿Í µ¿ÀÏÇÏÁö¸¸ '||'(¿¬°á ¿¬»êÀÚ)°¡ '+'·Î ¹Ù²ñ. ||¸¦ »ç¿ëÇÏ´Â ´Ù¸¥ SQL º¯Á¾À¸·ÎºÎÅÍ ½ºÅ©¸³Æ®¸¦ Æ÷ÆÃÇϴµ¥ À¯¿ë.

Y/N Mssql Ŭ¶óÀ̾ðÆ®

Unix¿Í Windows.
Unix ¼³Ä¡ ±æÀâÀÌ
.

mysql A Æ®·¢Àè¼ÇÀ» Áö¿øÇÏÁö ¾Ê´Â MySQL. ¿¬°áÇϱâ Àü¿¡ $db->clientFlags ¸¦ ¼³Á¤ÇÒ ¼ö ÀÖÀ½. Y/N MySQL Ŭ¶óÀ̾ðÆ® Unix¿Í Windows
mysqlt ¶Ç´Â maxsql A

Æ®·£Àè¼ÇÀ» Áö¿øÇÏ´Â MySQL. ÃÖÀûÀÇ ¼º´ÉÀ» À§ÇØ ¿¬°á ¿¬»êÀÚ·Î ||¸¦ »ç¿ëÇÒ °ÍÀ» ±Ç°í. ÀÌ °ÍÀº MySQL¸¦ mysqld --ansi³ª mysqld --sql-mode=PIPES_AS_CONCAT·Î ±âµ¿ÇÔÀ¸·Î¼­ »ç¿ëÇÒ ¼ö ÀÖÀ½

Y/N MySQL Ŭ¶óÀ̾ðÆ® Unix¿Í Windows
oci8 A Oracle 8/9. oracleº¸´Ù ±â´ÉÀûÀ¸·Î ÈξÀ ¿ì¼öÇÔ(¿¹. Affected_Rows). Connect/PConnectÀü¿¡ putenv('ORACLE_HOME=...')¸¦ ¼³Á¤ÇÒ ¼ö ÀÖÀ½.

2°¡Áö ¿¬°á ¹æ¹ý Á¦°ø - ¼­¹ö IP/¼­ºñ½º À̸§:
PConnect('serverip:1521','scott','tiger','service')
¶Ç´Â TNSNAMES.ORAÀÇ Ç׸ñ, ONAMES ¶Ç´Â HOSTNAMES »ç¿ë:
PConnect(false, 'scott', 'tiger', $oraname).

2.31 ÀÌ»ó ¹öÀüÀº Oracle REF Ä¿¼­ º¯¼ö¸¦ Á÷Á¢ Áö¿øÇÔ(ExecuteCursor¸¦ º¸±â ¹Ù¶÷).

Y/N Oracle Ŭ¶óÀ̾ðÆ® Unix¿Í Windows
oci805 C Oracle 8.0.5¿¡´ëÇØ Á¦ÇÑÀûÀÎ Oracle ±â´É Áö¿ø. SelectLimit´Â oci8³ª oci8po¿¡¼­Ã³·³ È¿°úÀûÀÌÁö ¸øÇÔ. Y/N Oracle Ŭ¶óÀ̾ðÆ® Unix¿Í Windows
oci8po A ȣȯ¼º ÀÖ´Â Oracle 8/9µå¶óÀ̹ö. ÀÌ µå¶óÀ̹ö´Â oci8 µå¶óÀ̹ö¿Í °ÅÀÇ µ¿ÀÏÇÏÁö¸¸ (a) Prepare()ÀÇ ¹ÙÀÎµå º¯¼ö¿¡ :bindvar ´ë½Å ?¸¦ »ç¿ëÇϸç, (b) Çʵå¸í¿¡ ¼Ò¹®ÀÚ¸¦ »ç¿ëÇÏ´Â °ÍÀÌ ´Ù¸§.

´Ù¸¥ µ¥ÀÌŸ º£À̽º·Î Æ÷ÆÃÇÏ´Â °ÍÀÌ Áß¿äÇÑ °æ¿ì ÀÌ µå¶óÀ̹ö¸¦ »ç¿ëÇÏ´Â °ÍÀÌ ÁÁÀ½. ±×·¸Áö¾ÊÀº °æ¿ì º¸´Ù ³ªÀº ¼ºÀ» À§ÇØ oci8 µå¶óÀ̹ö¸¦ »ç¿ëÇÏ´Â °ÍÀÌ ¹Ù¶÷Á÷ÇÔ.

Y/N Oracle Ŭ¶óÀ̾ðÆ® Unix¿Í Windows
odbc A ÀÏ¹Ý ODBC(ƯÁ¤ DB·Î Æ©´×µÇÁö¾ÊÀº ODBC). Á¢¼ÓÀ» À§ÇØ
PConnect('DSN','user','pwd')¸¦ »ç¿ë. ÀÌ µå¶óÀ̹ö´Â ¸ðµç ODBC µå¶óÀ̹öÀÇ ±âº» µå¶óÀ̹öÀÓ..
?´Â DB¿¡µû¶ó ´Ù¸§ ODBC Unix¿Í Windows. Unix ÈùÆ®.
odbc_mssql C ODBC·Î MSSQL¿¡ ¿¬°áÇÒ ¶§ »ç¿ë Y/N ODBC Unix¿Í Windows.
odbc_oracle C ODBC·Î Oracle¿¡ ¿¬°áÇÒ ¶§ »ç¿ë Y/N ODBC Unix¿Í Windows.
oracle C ±¸Çü Oracle 7 Ŭ¶óÀ̾ðÆ® API·Î ±¸Çö. º¸´Ù ³ªÀº ¼º´ÉÀ» À§ÇØ °¡´ÉÇÑ oci8 µå¶óÀ̹ö¸¦ »ç¿ëÇϱ⠹ٶ÷. Y/N Oracle Ŭ¶óÀ̾ðÆ® Unix¿Í Windows
postgres A ÀÏ¹Ý PostgreSQL µå¶óÀ̹ö. ÇöÀç postgres7 µå¶óÀ̹ö¿Í µ¿ÀÏ. Y PostgreSQL Ŭ¶óÀ̾ðÆ® Unix¿Í Windows.
postgres64 A ³»ºÎÀûÀ¸·Î LIMIT¸¦ Áö¿øÇÏÁö¾Ê´Â PostgreSQL 6.4 ÀÌÇÏ¿¡¼­ »ç¿ë. Y PostgreSQL Ŭ¶óÀ̾ðÆ® Unix¿Í Windows.
postgres7 A LIMIT¿Í ¹öÀü 7 ±â´ÉÀ» Áö¿øÇÏ´Â PostgreSQL¿¡¼­ »ç¿ë. Y PostgreSQL Ŭ¶óÀ̾ðÆ® Unix¿Í Windows.
sapdb C SAP DB. ½Å·Ú¼ºÀÖ´Â µ¿ÀÛÀº ODBC µå¶óÀ̹ö¸¦ »ç¿ëÇØ¾ß ÇÔ. Y/N SAP ODBC Ŭ¶óÀ̾ðÆ®

?

sqlanywhere C Sybase SQL Anywhere. ½Å·Ú¼ºÀÖ´Â µ¿ÀÛÀº ODBC µå¶óÀ̹ö¸¦ »ç¿ëÇØ¾ß ÇÔ. Y/N SQL Anywhere ODBC Ŭ¶óÀ̾ðÆ®

?

sqlite B SQLite. PHP5¿¡¼­¸¸ Å×½ºÆ®ÇÔ. Y -

Unix¿Í Windows.

sybase C Sybase. Y/N Sybase Ŭ¶óÀ̾ðÆ®

Unix¿Í Windows.

"°Ë»ç" Ä÷³Àº ÄÚµåÀÇ °Ë»ç »óÅÂ¿Í »ç¿ë »óŸ¦ ³ªÅ¸³½´Ù.
A = ¸¹Àº »ç¶÷¿¡ÀÇÇØ ¿©·¯¹ø °ËnfµÇ¾úÀ¸¸ç ¸¹Àº »ç¶÷µéÀÌ »ç¿ëÇÏ°í ÀÖÀ½
B = ÀϺΠ»ç¶÷µé¿¡ÀÇÇØ °Ë»çµÇ¾ú°í »ç¿ëÁßÀÌÁö¸¸ ¸î¸î Ư¡ÀÌ ±¸ÇöµÇÁö ¾Ê¾ÒÀ» ¼ö ÀÖÀ½
C = »ç¿ëÀÚ°¡ Á¦°øÇÑ Äڵ峪 ½ÇÇèÀûÀÎ µå¶óÀ̹ö. ADOdb ÃֽŠ¹öÀüÀÇ ¸ðµç Ư¡À» ¿ÏÀüÈ÷ Áö¿øÇÏÁö ¸øÇÒ ¼ö ÀÖÀ½.

"RecordCount() Áö¿ø" Ä÷³Àº SELECT ¹®ÀÌ ½ÇÇàµÉ ¶§ RecordCount()°¡ Çà¼ö¸¦ ¸®ÅÏÇÏ´ÂÁö -1À» ¸®ÅÏÇÏ´ÂÁö¸¦ ÀǹÌÇÑ´Ù. ¸¸¾à Ä÷³ÀÌ Y/N¶ó¸é RecordCount()´Â Àü¿ªº¯¼ö $ADODB_COUNTRECS°¡ ÂüÀ¸·Î ¼³Á¤(±âº»°ª)µÉ ¶§ ¿¡¹Ä·¹ÀÌÆ®µÈ´Ù. ´ëÇü ·¹ÄÚµå¼ÂÀÇ °æ¿ì RecordCount() ¿¡¹Ä·¹À̼ÇÀ» »ç¿ëÇÏÁö ¾Ê´Â °ÍÀÌ ÁÁ´Ù. ¿Ö³ÄÇÏ¸é ´ëÇü ·¹ÄÚµå¼ÂÀ» ij½¬ÇϱâÀ§ÇØ ¸¹Àº ·®ÀÇ ¸Þ¸ð¸®°¡ ÇÊ¿äÇϱ⶧¹®¿¡´Ù. ¶ÇÇÑ ¿¡¹Ä·¹À̼ÇÀ» »ç¿ëÇÏ´Â °æ¿ì 40-50%ÀÇ ¼º´ÉÀÌ °¨¼ÒÇÑ´Ù. PostgreSQL°ú MySQLÀ» Á¦¿ÜÇÑ µ¥ºÎºÐÀÇ DB¿¡¼­ ÀÌ ±â´ÉÀº ¿¡¹Ä·¹À̼ÇÀ¸·Î ±¸ÇöµÈ´Ù.


±æÀâÀÌ

¿¹ 1: Select ¹®

ÀÛ¾÷: Access Northwind DSN¿¡ ¿¬°áÇÏ°í °¢ÇàÀÇ Ã¹ 2°³ÀÇ Ä÷³À» Ãâ·Â.

ÀÌ ¿¹¿¡¼­ µ¥ÀÌŸº£À̽º¿¡´ëÇÑ ¿¬°áÀ» Ç¥ÇöÇÏ´Â ADOConnection °³Ã¼¸¦ »ý¼ºÇÑ´Ù. Á¢¼ÓÀº PConnect(¿µ±¸ Á¢¼Ó)·Î ÃʱâÈ­µÈ´Ù. µ¥ÀÌŸº£À̽º¿¡ ÁúÀÇÇϱâÀ§ÇØ ADOConnection.Execute() ÇÔ¼ö¸¦ È£ÃâÇÑ´Ù. ÀÌ ÇÔ¼ö´Â fields[] ¹è¿­·Î ÇöÀçÇà¿¡´ëÇÑ Ä¿¼­¸¦ Áö½ÃÇÏ°í ÀÖ´Â ADORecordSet °³Ã¼¸¦ ¸®ÅÏÇÑ´Ù. Çà¿¡¼­ ÇàÀ¸·Î À̵¿ÇϱâÀ§ÇØ MoveNext()¸¦ »ç¿ëÇÑ´Ù.

NB: ÀÌ ¿¹¿¡¼­ »ç¿ëµÇÁö¾ÊÀº À¯¿ëÇÑ ÇÔ¼ö´Â SelectLimit·Î ÀÌ ÇÔ¼ö´Â Ãâ·ÂµÉ ÇàÀÇ ¼ö¸¦ Á¦ÇÑÇÒ ¼ö ÀÖ´Ù.

<?
include('adodb.inc.php');	   # ADOdb °øÅë ÄÚµå ÀÐÀ½
$conn = &ADONewConnection('access');	# Á¢¼Ó »ý¼º
$conn->PConnect('northwind');   # MS-Access, northwind DSN¿¡ ¿¬°á
$recordSet = &$conn->Execute('select * from products');
if (!$recordSet) 
	print $conn->ErrorMsg();
else
while (!$recordSet->EOF) {
	print $recordSet->fields[0].' '.$recordSet->fields[1].'<BR>';
	$recordSet->MoveNext();
}

$recordSet->Close(); # ¿É¼Ç
$conn->Close(); # ¿É¼Ç

?>

¸®ÅÏµÈ $recordSetÀº $recordSet->fields ¹è¿­¿¡ ÇöÀçÇàÀ» ÀúÀåÇÏ°í ÀÖ´Ù. ÀÌ ¹è¿­Àº ¿µ¿¡¼­ ½ÃÀÛÇϸç Ä÷³ ¹øÈ£¿¡ÀÇÇØ ÂüÁ¶µÈ´Ù. ´ÙÀ½ ÇàÀ¸·Î À̵¿ÇϱâÀ§ÇØ MoveNext() ÇÔ¼ö¸¦ »ç¿ëÇÑ´Ù. EOF ¼Ó¼ºÀº ÆÄÀϳ¡(End of File)¿¡ µµ´ÞÇϸé ÂüÀ¸·Î ¼³Á¤µÈ´Ù. Execute()¿¡¼­ ¿À·ù°¡ ¹ß»ýÇÏ¸é ·¹ÄÚµå¼Â ´ë½Å °ÅÁþÀÌ ¸®ÅϵȴÙ.

$recordSet->fields[] ¹è¿­Àº PHP µ¥ÀÌŸº£À̽º È®Àå ¸ðµâ¿¡ÀÇÇØ »ý¼ºµÈ´Ù. ¸î¸î µ¥ÀÌŸº£À̽º È®Àå ¸ðµâÀº ´ÜÁö ¼ýÀÚ¿¡ÀÇÇؼ­¸¸ ÂüÁ¶ÇÒ ¼ö ÀÖ°í Çʵå À̸§¿¡ÀÇÇؼ­´Â ÂüÁ¶ÇÒ ¼ö ¾ø´Â ¹è¿­À» ¸®ÅÏÇÑ´Ù. °­Á¦·Î Çʵå À̸§¿¡ÀÇÇØ ÂüÁ¶(¿¬°ü¹è¿­)ÇϱâÀ§ÇØ SetFetchMode ÇÔ¼ö¸¦ »ç¿ëÇÒ ¼ö ÀÖ´Ù. °¢°¢ÀÇ ·¹ÄÚµå¼ÂÀº Execute()³ª SelectLimit()¿¡ÀÇÇØ »ý¼ºµÉ¶§ÀÇ ÆäÄ¡ ¸ðµå¿¡µû¶ó ÀúÀå, »ç¿ëµÈ´Ù.

	$db->SetFetchMode(ADODB_FETCH_NUM);
	$rs1 = $db->Execute('select * from table');
	$db->SetFetchMode(ADODB_FETCH_ASSOC);
	$rs2 = $db->Execute('select * from table');
	print_r($rs1->fields); # array([0]=>'v0',[1] =>'v1')¸¦ Ãâ·Â
	print_r($rs2->fields); # array(['col1']=>'v0',['col2'] =>'v1')¸¦ Ãâ·Â

Select ¹®¿¡ÀÇÇØ »ý¼ºµÈ Çà ¼ö¸¦ ¾ò±âÀ§ÇØ $recordSet->RecordCount()¸¦ »ç¿ëÇÒ ¼ö ÀÖ´Ù. ÁÖÀÇ: ¸®ÅÏµÈ ÇàÀÇ ¼ö¸¦ °áÁ¤ÇÒ ¼ö ¾ø´Â °æ¿ì -1ÀÌ ¸®ÅϵȴÙ.

¿¹ 2: ÇÊµå °³Ã¼·Î °Ë»ö Çϱâ

Å×À̺íÀ» °Ë»öÇÏ°í ù µÎ Ä÷³À» Ãâ·ÂÇÑ´Ù. ¸¸¾à µÎ¹ø° Ä÷³ÀÌ ³¯Â¥ ¶Ç´Â ŸÀÓ½ºÅÆÇÁ¶ó¸é US ³¯Â¥ Çü½ÄÀ¸·Î º¯È¯µÈ´Ù.

<?
include('adodb.inc.php');	   # ADOdb °øÅë ÄÚµå Àбâ
$conn = &ADONewConnection('access');	# Á¢¼Ó »ý¼º
$conn->PConnect('northwind');   # MS-Access, northwind dsn¿¡ ¿¬°á
$recordSet = &$conn->Execute('select CustomerID,OrderDate from Orders');
if (!$recordSet) 
	print $conn->ErrorMsg();
else
while (!$recordSet->EOF) {
	$fld = $recordSet->FetchField(1);
	$type = $recordSet->MetaType($fld->type);

	if ( $type == 'D' || $type == 'T') 
		print $recordSet->fields[0].' '.
			$recordSet->UserDate($recordSet->fields[1],'m/d/Y').'<BR>';
	else 
		print $recordSet->fields[0].' '.$recordSet->fields[1].'<BR>';

	$recordSet->MoveNext();
}
$recordSet->Close(); # ¿É¼Ç
$conn->Close(); # ¿É¼Ç

?>

ÀÌ ¿¹¿¡¼­ µÎ¹ø° Ä÷³ÀÇ ÇʵåÇüÀ» FetchField()¸¦ »ç¿ëÇؼ­ °Ë»çÇÑ´Ù. ÀÌ ÇÔ¼ö´Â Àû¾îµµ 3°³ Çʵ带 °®´Â °³Ã¼¸¦ ¸®ÅÏÇÑ´Ù.

±×¸®°í DB °íÀ¯ÀÇ ÇʵåÇüÀ» ÀϹÝÇüÀ¸·Î º¯È¯ÇϱâÀ§ÇØ MetaType()¸¦ »ç¿ëÇÑ´Ù. ÇöÀç ´ÙÀ½°ú °°Àº ÀϹÝÇüÀÌ Á¤ÀǵǾîÀÖ´Ù:

metatypeÀÌ ³¯Â¥³ª ŸÀÓ½ºÅÆÇÁ¶ó¸é UserDate()¸¦ »ç¿ëÇؼ­ PHP, SQL Çü½ÄÀÇ ³¯Â¥¸¦ »ç¿ëÀÚ°¡ Á¤ÀÇÇÑ Çü½ÄÀ¸·Î º¯È¯ÇÑ´Ù. MetaType()Àº SQL·Î Insert³ª Update¸¦ ÇϱâÀü µ¥ÀÌŸ¸¦ °ËÁõÇÒ ¶§ »ç¿ëÇÒ ¼ö ÀÖ´Ù.

¿¹ 3: »ðÀÔ

³¯Â¥¿Í ¹®ÀÚ¿­À» Æ÷ÇÔÇÏ´Â ÇàÀ» Orders Å×ÀÌºí¿¡ »ðÀÔÇÑ´Ù. À̶§ »ðÀÔÇÏ´Â ¹®ÀÚ¿­¿¡ John's¿Í°°ÀÌ ÀÛÀº µû¿ÈÇ¥°¡ Æ÷ÇÔµÈ °æ¿ì DB¿¡ »ðÀÔÇÒ ¼ö ÀÖµµ·Ï ÀοëÇÑ´Ù.

<?
include('adodb.inc.php');	   # ADOdb °øÅë ÄÚµå Àбâ
$conn = &ADONewConnection('access');	# Á¢¼Ó »ý¼º

$conn->PConnect('northwind');   # MS-Access, northwind DSN¿¡ ¿¬°á
$shipto = $conn->qstr("John's Old Shoppe");

$sql = "insert into orders (customerID,EmployeeID,OrderDate,ShipName) ";
$sql .= "values ('ANATR',2,".$conn->DBDate(time()).",$shipto)";

if ($conn->Execute($sql) === false) {
	print 'error inserting: '.$conn->ErrorMsg().'<BR>';
}
?>

ÀÌ ¿¹¿¡¼­ ADOdbÀÇ º¸°­µÈ ³¯Â¥ ¹× Àοë ó¸® ´É·ÂÀ» ¾Ë ¼ö ÀÖ´Ù. Unix ŸÀÓ½ºÅÆÇÁ(ÀϹÝÀûÀ¸·Î Long IntegerÀÎ)´Â DBDate()¸¦ »ç¿ëÇؼ­ Access¿¡ Àû´çÇÑ Çü½ÄÀ¸·Î º¯È¯µÇ°í, ¿Ã¹Ù¸¥ Escape ¹®ÀÚ°¡ John's Old Shoppe¸¦ ÀοëÇϴµ¥ »ç¿ëµÈ´Ù. Áï, PHPÀÇ ±âº»°ªÀÎ John's Old Shoppe°¡ ¾Æ´Ï¶ó qstr()¸¦ »ç¿ëÇؼ­ John''s Old Shoppe·Î ÀοëµÈ´Ù.

Execute ¹®ÀÇ ¿À·ù 󸮿¡ ÁÖÀÇÇϱ⠹ٶõ´Ù. ¸¸¾à ¿À·ù°¡ ¹ß»ýÇϸé Execute() ´Â °ÅÁþÀ» ¸®ÅÏÇÑ´Ù. ¸¶Áö¸· ¿À·ù¿¡´ëÇÑ ¿À·ù ¸Þ½ÃÁö´Â ErrorMsg()·Î Ãâ·ÂµÈ´Ù. ÁÖÀÇ: ¿À·ù ¸Þ½ÃÁö¸¦ ÀúÀåÇϱâÀ§ÇØ php_track_errors¸¦ »ç¿ëÇÒ ¼ö ÀÖ¾î¾ß ÇÑ´Ù.

¿¹ 4: µð¹ö±ë

<?
include('adodb.inc.php');	   # ADOdbÀÇ °øÅë ÄÚµå Àбâ
$conn = &ADONewConnection('access');	# Á¢¼Ó »ý¼º
$conn->PConnect('northwind');   # MS-Access, northwind DSN¿¡ ¿¬°á
$shipto = $conn->qstr("John's Old Shoppe");
$sql = "insert into orders (customerID,EmployeeID,OrderDate,ShipName) ";
$sql .= "values ('ANATR',2,".$conn->FormatDate(time()).",$shipto)";
$conn->debug = true;
if ($conn->Execute($sql) === false) print 'error inserting';
?>

À§ÀÇ ¿¹¿¡¼­´Â debug = true·Î ¼³Á¤ÇÔÀ¸·Î¼­ µð¹ö±ë ¸ðµå·Î ¼³Á¤Çß´Ù. µð¹ö±ë ¸ðµå¸¦ ¼³Á¤Çϸé SQL ¹®À» ½ÇÇàÇϱâÀü¿¡ SQL ¹®ÀåÀÌ Ãâ·ÂµÇ¸ç, ÀÓÀÇÀÇ ¿À·ù ¸Þ½ÃÁö ¿ª½Ã ÇÔ²² Ãâ·ÂµÈ´Ù. µð¹ö±ë ¸ðµå¸¦ »ç¿ëÇÒ ¶§¿¡´Â ErrorMsg() ÇÔ¼ö¸¦ È£ÃâÇÒ ÇÊ¿ä°¡¾ø´Ù. ·¹ÄÚµå¼ÂÀ» Ãâ·ÂÇϱâÀ§Çؼ­´Â rs2html() ÀÇ ¿¹¸¦ º¸±â ¹Ù¶õ´Ù.

¶ÇÇÑ »ç¿ëÀÚ ¿À·ù 󸮸¦ º¸±â¹Ù¶õ´Ù.

¿¹ 5: MySQL°ú ¸Þ´º

MySQL agora µ¥ÀÌŸº£À̽º¿¡ ¿¬°áÇÏ°í SQL ¹®À» ½ÇÇàÇÑ °á°ú·ÎºÎÅÍ <select> ¸Þ´º¸¦ »ý¼ºÇÑ´Ù. È­¸é¿¡ Ãâ·ÂµÇ´Â <option> °ªÀº ù¹ø° Ä÷³ÀÌ »ç¿ëµÇ¸ç ¼­¹ö·Î Àü¼ÛµÇ´Â °ªÀº µÎ¹ø° Ä÷³ÀÌ »ç¿ëµÈ´Ù.

<?
include('adodb.inc.php'); # ADOdb °øÅë ÄÚµå Àбâ
$conn = &ADONewConnection('mysql');  # Á¢¼Ó »ý¼º
$conn->PConnect('localhost','userid','','agora');# MySQL, agora µ¥ÀÌŸ º£À̽º¿¡ ¿¬°á
$sql = 'select CustomerName, CustomerID from customers';
$rs = $conn->Execute($sql);
print $rs->GetMenu('GetCust','Mary Rosli');
?>

ÀÌ ¿¹´Â GetCust(Select ű×ÀÇ À̸§)¶ó´Â ¸Þ´º¸¦ Á¤ÀÇÇÏ°í, ±âº»°ªÀ¸·Î 'Mary Rosli'¸¦ ÁöÁ¤ÇÑ ¿¹ÀÌ´Ù. GetMenu()¸¦ Âü°íÇϱâ¹Ù¶õ´Ù. ADOdb´Â ·¹ÄÚµå¼ÂÀ» ¹è¿­·Î¼­ ¸®ÅÏÇÏ´Â ÇÔ¼ö, GetArray()¸¦ °¡Áö°í ÀÖ´Ù. ¶ÇÇÑ Ã¹¹ø° Ä÷³À» Å°·ÎÇÏ´Â ¿¬°ü¹è¿­¸¦ ¸®ÅÏÇÏ´Â GetAssoc()µµ ÀÖ´Ù.

¿¹ 6: µ¿½Ã¿¡ 2°³ DB¿¡ Á¢¼ÓÇϱâ

<?
include('adodb.inc.php');	 # ADOdb °øÅë ÄÚµå
$conn1 = &ADONewConnection('mysql');  # mysql Á¢¼Ó »ý¼º
$conn2 = &ADONewConnection('oracle');  # oracle Á¢¼Ó »ý¼º

$conn1->PConnect($server, $userid, $password, $database);
$conn2->PConnect(false, $ora_userid, $ora_pwd, $oraname);

$conn1->Execute('insert ...');
$conn2->Execute('update ...');
?>

¿¹ 7: Update¿Í Insert SQL¹® »ý¼º

ADOdb 1.31 ÀÌ»óÀº µÎ°³ÀÇ »õ·Î¿î ·¹ÄÚµå¼Â ÇÔ¼ö, GetUpdateSQL( )°ú GetInsertSQL( )À» Áö¿øÇÑ´Ù. ÀÌ ÇÔ¼ö¸¦ »ç¿ëÇϸé "SELECT * FROM table query WHERE..."¸¦ ½ÇÇàÇÏ°í $rs->fields »çº»À» »ý¼º, Çʵ带 º¯°æÇÏ°í ÀÚµ¿ÀûÀ¸·Î Å×À̺íÀ» »ðÀÔ, °»½ÅÇÒ ¼ö ÀÖ´Â SQL ¹®À» »ý¼ºÇÒ ¼ö ÀÖ´Ù.

´ÙÀ½ ¿¹´Â (ID, FirstName, LastName, Created) Çʵ带 °®´Â Å×ÀÌºí¿¡ Á¢±ÙÇÒ ¶§ ÀÌ ÇÔ¼ö¸¦ ¾î¶»°Ô »ç¿ëÇÒ ¼ö ÀÖ´ÂÁö¸¦ º¸ÀÌ°í ÀÖ´Ù.

ÀÌ ÇÔ¼ö¸¦ È£ÃâÇϱâÀü Å×ÀÌºí¿¡´ëÇØ SELECT ¹®À» ¼öÇàÇÔÀ¸·Î¼­ ·¹ÄÚµå¼ÂÀ» ÃʱâÈ­ÇÒ ÇÊ¿ä°¡ ÀÖ´Ù. ´ÙÀ½ ÄÚµå´Â Jonathan Younger(jyounger#unilab.com)ÀÇ »ý°¢ÀÌ´Ù.

<?
#==============================================
# °£´ÜÇÑ GetUpdateSQL()°ú GetInsertSQL() ÄÚµå
#==============================================
include('adodb.inc.php');
include('tohtml.inc.php');

#==========================
# INSERT Å×½ºÆ®

$sql = "SELECT * FROM ADOXYZ WHERE id = -1"; 
# ºó ·¹Äڵ带 °Ë»ö

$conn = &ADONewConnection("mysql");  # Á¢¼Ó »ý¼º
$conn->debug=1;
$conn->PConnect("localhost", "admin", "", "test"); # MySQL, testdb¿¡ ¿¬°á
$rs = $conn->Execute($sql); # ÁúÀǸ¦ ¼öÇàÇÏ°í ºó ·¹ÄÚµå¼ÂÀ» °¡Á®¿È

$record = array(); # ·¹ÄÚµå µ¥ÀÌŸ¸¦ ÀúÀåÇÒ ¹è¿­À» ÃʱâÈ­

# »ðÀÔÇÒ ·¹ÄÚµåÀÇ Çʵå¿Í °ªÀ» ¼³Á¤
# ÁÖÀÇ: Çʵå¸íÀº ´ë¼Ò¹®ÀÚ¸¦ ±¸ºÐÇÔ
$record["firstname"] = "Bob";
$record["lastNamE"] = "Smith";
$record["creaTed"] = time();

# ºó ·¹ÄÚµå¼Â°ú »ðÀÔÇÒ µ¥ÀÌŸ¸¦ Æ÷ÇÔÇÏ´Â ¹è¿­À» GetInsertSQL ÇÔ¼ö¿¡ Àü´Þ
# ÀÌ ÇÔ¼ö´Â µ¥ÀÌŸ¸¦ ó¸®ÇÏ°í ¿ÏÀüÈ÷ Çü½ÄÈ­µÈ INSERT SQL ¹®À» ¸®ÅÏÇÔ
$insertSQL = $conn->GetInsertSQL($rs, $record);

$conn->Execute($insertSQL); # µ¥ÀÌŸ º£À̽º¿¡ »ðÀÔ

#==========================
# UPDATE Å×½ºÆ®

$sql = "SELECT * FROM ADOXYZ WHERE id = 1"; 
# °»½ÅÇÒ ·¹Äڵ带 °Ë»ö

$rs = $conn->Execute($sql); # ÁúÀǸ¦ ¼öÇàÇÏ°í ¾÷µ¥ÀÌÆ®ÇÒ ·¹Äڵ带 °¡Á®¿È

$record = array(); # ·¹ÄÚµåÀÇ µ¥ÀÌŸ¸¦ ÀúÀåÇÒ ¹è¿­À» ÃʱâÈ­

# °»½ÅÇÒ ·¹ÄÚµåÀÇ Çʵå¿Í °ªÀ» ¼³Á¤
# ÁÖÀÇ: Çʵå¸íÀº ´ë¼Ò¹®ÀÚ¸¦ ±¸ºÐÇÔ
$record["firstname"] = "Caroline";
$record["LasTnAme"] = "Smith"; # CarolineÀÇ ¼ºÀ» Miranda¿¡¼­ Smith·Î °»½Å

# ÇϳªÀÇ ·¹ÄÚµå¼Â°ú °»½ÅÇÒ µ¥ÀÌŸ¸¦ Æ÷ÇÔÇÏ´Â ¹è¿­À» GetUpdateSQL ÇÔ¼ö¿¡ Àü´Þ
# ÀÌ ÇÔ¼ö´Â µ¥ÀÌŸ¸¦ ó¸®ÇÏ°í ¿ÏÀüÈ÷ Çü½ÄÈ­µÈ UPDATE SQL ¹®À» ¸®ÅÏÇÔ
# ¿Ã¹Ù¸¥ WHERE ¹® ¿ª½Ã Æ÷ÇÔµÊ
# Å×ÀÌŸ°¡ °»½ÅµÇÁö¾Ê´Â °æ¿ì ¾î¶°ÇÑ ·¹ÄÚµå¼Âµµ ¸®ÅϵÇÁö¾ÊÀ½
$updateSQL = $conn->GetUpdateSQL($rs, $record);

$conn->Execute($updateSQL); # DBÀÇ ·¹Äڵ带 °»½Å
$conn->Close();
?>

¿¹ 8: ÆäÀÌÁö À̵¿ ±¸Çö

´ÙÀ½Àº ¾ÆÁÖ °£´ÜÇÑ ·¹ÄÚµå¼Â ÆäÀÌÁö À̵¿±â¸¦ ¸¸µç´Ù. µû¶ó¼­ ·¹ÄÚµå¼ÂÀ» ÆäÀÌÁö ´ÜÀ§·Î À̵¿½Ãų ¼ö ÀÖ´Ù.

include_once('../adodb.inc.php');
include_once('../adodb-pager.inc.php');
session_start();

$db = NewADOConnection('mysql');

$db->Connect('localhost','root','','xphplens');

$sql = "select * from adoxyz ";

$pager = new ADODB_Pager($db,$sql);
$pager->Render($rows_per_page=5);

ÀÌ ÇÔ¼ö´Â ´ÙÀ½ ǥó·³ ±âº» ·¹ÄÚµå ÆäÀÌÀú¸¦ »ý¼ºÇÑ´Ù:

|<   <<   >>   >|  
ID First Name Last Name Date Created
36  Alan  Turing  Sat 06, Oct 2001 
37  Serena  Williams  Sat 06, Oct 2001 
38  Yat Sun  Sun  Sat 06, Oct 2001 
39  Wai Hun  See  Sat 06, Oct 2001 
40  Steven  Oey  Sat 06, Oct 2001 
Page 8/10

Çѹø¿¡ Ãâ·ÂÇÒ ÇàÀÇ ¼ö´Â Render($rows) ¸Þ¼Òµå¿¡ÀÇÇØ º¯°æÇÒ ¼ö ÀÖ´Ù. ¸¸¾à Render()¿¡ ÀÎÀÚ¸¦ Àü´ÞÇÏÁö ¾Ê´Â °æ¿ì ADODB_Pager´Â ±âº»°ªÀÎ ÆäÀÌÁö´ç 10 ÇàÀ¸·Î ¼³Á¤µÈ´Ù.

Çʵå¸íÀº SQLÀ» º¯°æÇÔÀ¸·Î ¹Ù²Ü ¼ö ÀÖ´Ù(´ëºÎºÐÀÇ DB¿¡¼­ Áö¿ø):

$sql = 'select id as "ID", firstname as "First Name", 
		  lastname as "Last Name", created as "Date Created" 
from adoxyz';

À§ÀÇ ÄÚµå´Â ÀÌ ¹èÆ÷º»¿¡ Æ÷ÇÔµÈ adodb/tests/testpaging.php¿Í adodb/adodb-pager.inc.php¿¡¼­ ãÀ» ¼ö ÀÖ´Ù. ADODB_Pager´Â ÇÁ·Î±×·¡¸Ó¿¡ÀÇÇØ º¯°æµÉ ¼ö ÀÖ´Ù. µû¶ó¼­ ÅؽºÆ® ¸µÅ©´Â À̹ÌÁö·Î º¯°æÇÒ ¼ö ÀÖÀ¸¸ç, ¹è°æ»ö ¿ª½Ã ¿øÇÏ´Â »ö»óÀ¸·Î º¯°æÇÒ ¼ö ÀÖ´Ù.

$pager->htmlSpecialChars = false¸¦ ¼³Á¤ÇÔÀ¸·Î¼­ HTMLµµ Ãâ·ÂÇÒ ¼ö ÀÖ´Ù.

¿©±â¼­ »ç¿ëµÈ ¸î¸î ÄÚµå´Â Iván Oliva°ú Cornel G ´öÅÃÀÌ´Ù.

¿¹ 9: CSV¿Í Tab ±¸ºÐ Çü½ÄÀ¸·Î ³»º¸³»±â

ADOdb´Â CSV(Comma-Separated-Value)¿Í ÅÇ ±¸ºÐ Çü½ÄÀ¸·Î Ãâ·ÂÇÒ ¼ö ÀÖ´Â º¸Á¶ ÇÔ¼ö¸¦ Á¦°øÇÑ´Ù.:

include_once('/path/to/adodb/toexport.inc.php');
include_once('/path/to/adodb/adodb.inc.php');
$db = &NewADOConnection('mysql');
$db->Connect($server, $userid, $password, $database);

$rs = $db->Execute('select fname as "First Name", surname as "Surname" from table');

print "<pre>";
print rs2csv($rs); # CSV Çü½ÄÀÇ ¹®ÀÚ¿­ ¸®ÅÏ

print '<hr>';

$rs->MoveFirst(); # ÁÖÀÇ: ¸î¸î DB´Â MoveFirst¸¦ Áö¿øÇÏÁö ¾ÊÀ½ print rs2tab($rs,false); # ÅÇ ±¸ºÐ Çü½ÄÀÇ ¹®ÀÚ¿­ ¸®ÅÏ # false·Î ¼³Á¤Çϸé ùÇàÀÇ Çʵå¸íÀ» Ãâ·ÂÇÏÁö ¾ÊÀ½ print '<hr>'; $rs->MoveFirst(); rs2tabout($rs); # Ç¥ÁØ Ãâ·ÂÀ¸·Î Á÷Á¢ Ãâ·ÂÇÔ(rs2csvout ÇÔ¼öµµ ÀÖÀ½) print "</pre>"; $rs->MoveFirst(); $fp = fopen($path, "w"); if ($fp) { rs2csvfile($rs, $fp); # ÆÄÀÏ·Î ÀúÀå(rs2tabfile ÇÔ¼öµµ ÀÖÀ½) fclose($fp); }

ij¸®Áö ¸®ÅÏ°ú °³ÇàÀº °ø¹éÀ¸·Î º¯È¯µÈ´Ù. Çʵå¸íÀº ùÇà¿¡ Ãâ·ÂµÈ´Ù. ÇÊµå ±¸ºÐÀÚ¸¦ Æ÷ÇÔÇÑ ¹®ÀÚ¿­À» Å«µû¿ÈÇ¥·Î ÀοëµÈ´Ù. Å« µû¿ÈÇ¥´Â Å«µû¿ÈÇ¥·Î ´Ù½Ã ÀοëµÈ´Ù. ÀÌ·¯ÇÑ ±â´É¶§¹®¿¡ ¿¢¼¿·Î °¡Á®¿À±â/³»º¸³»±â¸¦ ¾ÈÀüÇÏ°Ô ÇÒ ¼ö ÀÖ´Ù.

À§ÀÇ ¸ðµç ÇÔ¼ö¿¡¼­ ¸¶Áö¸· ¸Å°³º¯¼ö, $addtitles´Â ¿É¼ÇÀÌ´Ù. $addtitles´Â ±âº»ÀûÀ¸·Î ÂüÀ¸·Î ¼³Á¤µÈ´Ù. °ÅÁþÀ¸·Î ¼³Á¤µÇ¸é ùÇà¿¡ Çʵå¸íÀ» Ãâ·ÂÇÏÁö¾Ê´Â´Ù.

¿¹ 10: ·¹ÄÚµå¼Â ÇÊÅÍ

¶§¶§·Î ·¹ÄÚµå¼ÂÀ» »ç¿ëÇϱâÀü¿¡ ·¹ÄÚµå¼ÂÀÇ ¸ðµç ÇàÀ» ¹Ì¸® ó¸®ÇÒ ÇÊ¿ä°¡ ÀÖ´Ù. ¿¹¸¦µé¾î ·¹ÄÚµå¼ÂÀÇ ¸ðµç ¹®ÀÚ¿­¿¡´ëÇØ ucwords¸¦ ½ÇÇàÇÒ ¼ö ÀÖ´Ù.

include_once('adodb/rsfilter.inc.php');
include_once('adodb/adodb.inc.php');

// ·¹ÄÚµå¼ÂÀÇ ¸ðµç Ç׸ñ¿¡´ëÇØ ucwords()¸¦ È£Ãâ
function do_ucwords(&$arr,$rs)
{
	foreach($arr as $k => $v) {
		$arr[$k] = ucwords($v);
	}
}

$db = NewADOConnection('mysql');
$db->PConnect('server','user','pwd','db');

$rs = $db->Execute('select ... from table');
$rs = RSFilter($rs,'do_ucwords');

RSFilter ÇÔ¼ö´Â ¸Å°³º¯¼ö·Î ·¹ÄÚµå¼Â°ú ÇÊÅÍ ÇÔ¼öÀÇ À̸§À» ÃëÇÑ´Ù. ÀÌ ÇÔ¼ö´Â ·¹ÄÚµå¼ÂÀ» ÇÊÅÍÇÔ¼ö·Î ó¸®ÇÑ ÈÄ, ùÇàÀ¸·Î À̵¿µÈ ·¹ÄÚµå¼ÂÀ» ¸®ÅÏÇÑ´Ù. ÇÊÅÍ ÇÔ¼ö´Â ¸Å°³º¯¼ö·Î ÇöÀç ÇàÀ» Áö½ÃÇÏ´Â ¹è¿­°ú ·¹ÄÚµå¼Â °³Ã¼¸¦ ÃëÇÑ´Ù. ȣȯ¼ºÀ» À§ÇØ ¿ø·¡ÀÇ ·¹ÄÚµå¼Â °³Ã¼¸¦ »ç¿ëÇÏÁö¾Ê´Â °ÍÀÌ ÁÁ´Ù.

¿¹ 11: Áö´ÉÀû Æ®·£Àè¼Ç

ADOdbÀÇ ¿¹Àü ¹öÀü¿¡¼­ »ç¿ëÇÑ Æ®·£Àè¼ÇÀº ´ÙÀ½°ú °°´Ù.
$conn->BeginTrans();
$ok = $conn->Execute($sql);
if ($ok) $ok = $conn->Execute($sql2);
if (!$ok) $conn->RollbackTrans();
else $conn->CommitTrans();
ÀÌ °ÍÀº ´ëÇü ÇÁ·ÎÁ§Æ®ÀÇ °æ¿ì ¾ÆÁÖ º¹ÀâÇÏ´Ù. ¿Ö³ÄÇÏ¸é ¿À·ù »óŸ¦ °è¼Ó ÃßÀûÇØ¾ß Çϱ⶧¹®ÀÌ´Ù. Áö´ÉÀû Æ®·£Àè¼ÇÀº ÈξÀ °£´ÜÇÏ´Ù. StartTrans()¸¦ È£ÃâÇÔÀ¸·Î¼­ Æ®·£Àè¼ÇÀ» ½ÃÀÛÇÑ´Ù:
$conn->StartTrans();
$conn->Execute($sql);
$conn->Execute($Sql2);
$conn->CompleteTrans();
CompleteTrans()Àº SQL ¿À·ùÀÇ ¹ß»ý ¿©ºÎ¸¦ °ËÃâÇÏ°í ¿À·ù ¹ß»ý ¿©ºÎ¿¡µû¶ó Àû´çÈ÷ ·Ñ¹é/Ä¿¹ÔÇÑ´Ù. ¿À·ù°¡ ¹ß»ýÇÏÁö¾Ê¾Æµµ °­Á¦·Î ·Ñ¹éÇÏ·Á¸é FailTrans()¸¦ »ç¿ëÇÑ´Ù. ÁÖÀÇ: ·Ñ¹éÀº FailTrans()¿¡¼­°¡ ¾Æ´Ï¶ó CompleteTrans()¿¡¼­ ¼öÇàµÈ´Ù.
$conn->StartTrans();
$conn->Execute($sql);
if (!CheckRecords()) $conn->FailTrans();
$conn->Execute($Sql2);
$conn->CompleteTrans();

HasFailedTrans()¸¦ »ç¿ëÇؼ­ Æ®·¢Àè¼ÇÀÇ ½ÇÆп©ºÎ¸¦ °Ë»çÇÒ ¼ö ÀÖ´Ù. HasFailedTrans()Àº FailTrans()°¡ È£ÃâµÈ °æ¿ì³ª SQL ½ÇÇà¿¡ ¿À·ù°¡ ÀÖ´Â °æ¿ì ÂüÀ» ¸®ÅÏÇÑ´Ù.

¸¶Áö¸·À¸·Î StartTrans/CompleteTrans´Â ÁßøµÉ ¼ö ÀÖÁö¸¸ ÃÖ¿Ü°û ºí·°¸¸ ½ÇÇàµÈ´Ù. ¹Ý´ë·Î BeginTrans/CommitTrans/RollbackTrans´Â ÁßøµÉ ¼ö ¾ø´Ù.

$conn->StartTrans();
$conn->Execute($sql);
  $conn->StartTrans();    # ¹«½Ã
  if (!CheckRecords()) $conn->FailTrans();
  $conn->CompleteTrans(); # ¹«½Ã
$conn->Execute($Sql2);
$conn->CompleteTrans();

ÁÖÀÇ: Savepoints´Â ÇöÀç Áö¿øµÇÁö ¾Ê´Â´Ù.

»ç¿ëÀÚ ¿À·ùó¸®¿Í PEAR_Error

´Ù¹ö±ë ¹æ¹ýÀ¸·Î ¿¹ÀüºÎÅÍ Á¦°øµÇ´ø $con->debug = true¿Í´Â ´Þ¸® ADOdb 1.5 ÀÌ»óÀº ¶Ç ´Ù¸¥ µÎ°³ÀÇ ADOdbÀÇ »ç¿ëÀÚ ¿À·ù 󸮱⸦ Á¦°øÇÑ´Ù.

ADOdb´Â ÇÊ¿ä½Ã º¯°æÇÒ ¼ö ÀÖ´Â µÎ°³ÀÇ »ç¿ëÀÚ ¿À·ù 󸮱⸦ Á¦°øÇÑ´Ù. ù¹ø° ¿À·ù 󸮱â´Â adodb-errorhandler.inc.php¿¡ Á¸ÀçÇÑ´Ù. ÀÌ ¿À·ù󸮱â´Â Ãâ·ÂµÉ ¿À·ù ¸Þ½ÃÁö À¯ÇüÀ» Á¦¾îÇϱâÀ§ÇØ Ç¥ÁØ PHP ÇÔ¼ö, error_reporting¸¦ »ç¿ëÇϸç, PHPÀÇ ±âº» ¿À·ù 󸮱⸦ È£ÃâÇÏ´Â trigger_error¸¦ »ç¿ëÇÑ´Ù.

À§ÀÇ ÆÄÀÏÀ» IncludeÇÏ¸é ´ÙÀ½°ú °°Àº »óȲ¿¡¼­ trigger_error($errorstring,E_USER_ERROR)°¡ È£ÃâµÈ´Ù.
(a) Connect() ¶Ç´Â PConnect() ½ÇÆÐÇÒ ¶§
(b) Execute() ³ª SelectLimit()¿Í °°ÀÌ SQL ¹®À» ½ÇÇàÇÏ´Â ÇÔ¼ö°¡ ¿À·ù¸¦ ¹ß»ýÇÒ ¶§.
(c) GenID()°¡ ¹«ÇÑ ·çÇÁ¸¦ µ¹¶§.

$errorstringÀº ADOdb¿¡ÀÇÇØ »ý¼ºµÇ¸ç, ¾Æ·¡¿¡ »ý¼ºµÈ error.log µ¥ÀÌŸ¿Í ºñ½ÁÇÑ Á¤º¸¸¦ Æ÷ÇÔÇÏ°í ÀÖ´Ù. adodb-errorhandler.inc.php ÆÄÀÏÀº ADOConnection °³Ã¼¸¦ »ý¼ºÇϱâ Àü¿¡ Include ¹®À» ÀÌ¿ëÇؼ­ Æ÷ÇÔ½ÃÄÑ¾ß ÇÑ´Ù.

¸¸¾à error_reporting(0)¸¦ Á¤ÀÇÇÏ¸é ¾î¶°ÇÑ ¿À·ùµµ ¿À·ù 󸮱â·Î Àü´ÞµÇÁö¾Ê´Â´Ù. error_reporting(E_ALL)À» ¼³Á¤ÇÏ¸é ¸ðµç ¿À·ù°¡ ¿À·ù 󸮱â·Î Àü´ÞµÈ´Ù. ¿À·ùÀÇ Ãâ·ÂÀ» Á¦¾îÇϱâÀ§ÇØ ini_set("display_errors", "0" ¶Ç´Â "1")¸¦ »ç¿ëÇÒ ÇÊ¿ä°¡ ÀÖ´Ù.

<?php
error_reporting(E_ALL); # Æ®¸®°ÅµÈ ¸ðµç ¿À·ù¸¦ ¿À·ù 󸮱⿡ Àü´Þ
include('adodb-errorhandler.inc.php');
include('adodb.inc.php');
include('tohtml.inc.php');
$c = NewADOConnection('mysql');
$c->PConnect('localhost','root','','northwind');
$rs=$c->Execute('select * from productsz'); #productsz Å×À̺í À̸§ÀÌ À߸øµÊ
if ($rs) $rs2html($rs);
?>

¿À·ù ¸Þ½ÃÁö¸¦ ÆÄÀÏ¿¡ ±â·Ï, ÃßÀûÇÏ±æ ¿øÇÑ´Ù¸é ADODB_ERROR_LOG_TYPE°ú ADODB_ERROR_LOG_DEST »ó¼ö¸¦ Á¤ÀÇÇÔÀ¸·Î¼­ ¿À·ù ¸Þ½ÃÁö¸¦ ±â·Ï, ÃßÀûÇÒ ¼ö ÀÖ´Ù. ADODB_ERROR_LOG_TYPEÀº ¿À·ù ¸Þ½ÃÁö ±â·Ï À¯Çü(PHP ¸Å´º¾óÀÇ error_log¸¦ º¸±â ¹Ù¶õ´Ù)À» ³ªÅ¸³½´Ù. ´ÙÀ½ ¿¹¿¡¼­´Â 3À¸·Î ¼³Á¤ÇßÀ¸¸ç, ÀÌ °ÍÀº ADODB_ERROR_LOG_DEST »ó¼ö¿¡ÀÇÇØ Á¤ÀÇµÈ ÆÄÀÏ·Î ±â·ÏÇÏ´Â °ÍÀ» ÀǹÌÇÑ´Ù.

<?php
error_reporting(E_ALL); # ¸ðµç ¿À·ù¸¦ º¸°í
ini_set("display_errors", "0"); # ¿À·ù¸¦ È­¸é¿¡ Ãâ·ÂÇÏÁö ¾ÊÀ½
define('ADODB_ERROR_LOG_TYPE',3);
define('ADODB_ERROR_LOG_DEST','C:/errors.log');
include('adodb-errorhandler.inc.php');
include('adodb.inc.php');
include('tohtml.inc.php');

$c = NewADOConnection('mysql');
$c->PConnect('localhost','root','','northwind');
$rs=$c->Execute('select * from productsz'); ## productsz Å×À̺í À̸§ÀÌ À߸øµÊ
if ($rs) $rs2html($rs);
?>
´ÙÀ½ ¸Þ½ÃÁö°¡ error.log ÆÄÀÏ¿¡ ±â·ÏµÉ °ÍÀÌ´Ù.
(2001-10-28 14:20:38) mysql error: [1146: Table 'northwind.productsz' doesn't exist] in
 EXECUTE("select * from productsz")
µÎ¹ø° ¿À·ù 󸮱â´Â adodb-errorpear.inc.php ÆÄÀÏ¿¡ Á¸ÀçÇÑ´Ù. ÀÌ °ÍÀº ¿À·ù¸¦ ¹ß»ýÇÑ °³Ã¼·ÎºÎÅÍ À¯µµµÈ PEAR_Error¸¦ »ý¼ºÇÑ´Ù. »ý¼ºµÈ ¸¶Áö¸· PEAR_Error °³Ã¼´Â ADODB_Pear_Error()¸¦ »ç¿ëÇؼ­ º¹¿øÇÒ ¼ö ÀÖ´Ù.
<?php
include('adodb-errorpear.inc.php');
include('adodb.inc.php');
include('tohtml.inc.php');
$c = NewADOConnection('mysql');
$c->PConnect('localhost','root','','northwind');
$rs=$c->Execute('select * from productsz'); #productsz Å×À̺í À̸§ÀÌ À߸øµÊ;
if ($rs) $rs2html($rs);
else {
	$e = ADODB_Pear_Error();
	echo '<p>',$e->message,'</p>';
}
?>

adodb-errorpear.inc.php ÆÄÀÏÀ» Include ÇϱâÀü¿¡ »ó¼ö ADODB_PEAR_ERROR_CLASS¸¦ Á¤ÀÇÇÔÀ¸·Î¼­ Å©·¡½º·ÎºÎÅÍ ¹ß»ýÇÑ PEAR_Error¸¦ ÃßÀûÇÒ ¼ö ÀÖ´Ù. ½±°Ô µð¹ö±ëÇϱâ À§ÇØ PHP ½ºÅ©¸³Æ®ÀÇ ½ÃÀÛ ºÎºÐ¿¡ ±âº» ¿À·ù 󸮱⸦ PEAR_ERROR_DIE·Î ¼³Á¤ÇÒ ¼ö ÀÖ´Ù. PEAR_ERROR_DIE¸¦ »ç¿ëÇÔÀ¸·Î¼­ ¿À·ù ¸Þ½ÃÁö¸¦ Ãâ·ÂÇÏ°í, ½ºÅ©¸³Æ®ÀÇ ½ÇÇàÀ» ÁßÁöÇÒ ¼ö ÀÖ´Ù:

include('PEAR.php');
PEAR::setErrorHandling('PEAR_ERROR_DIE');

¿À·ù°¡ ¹ß»ýÇÒ ¶§ PEAR_Error °³Ã¼°¡ ¸í½ÃÀûÀ¸·Î ¸®ÅϵÇÁö¾Ê´Â´Ù´Â °Í¿¡ ÁÖÀÇÇϱ⠹ٶõ´Ù. ´ë½Å¿¡ °ÅÁþÀÌ ¸®ÅϵǸç, ¸¶Áö¸· ¿À·ù¸¦ ¾ò±âÀ§Çؼ­´Â ADODB_Pear_Error()¸¦ È£ÃâÇϰųª PEAR_ERROR_DIE ±â¹ýÀ» »ç¿ëÇØ¾ß ÇÑ´Ù.

¿À·ù ¸Þ½ÃÁö

¿À·ù ¸Þ½ÃÁö´Â Á¤Àû ¸Þ¼Òµå, ADOConnnection::outp($msg,$newline=true)¸¦ »ç¿ëÇؼ­ Ãâ·ÂµÈ´Ù. ±âº»ÀûÀ¸·Î ÀÌ ¸Þ¼Òµå´Â ¸Þ½ÃÁö¸¦ Ŭ¶óÀ̾ðÆ®·Î Àü¼ÛÇÑ´Ù. ±×·¯³ª ÇÊ¿äÇÑ °æ¿ì ¿À·ù ±â·ÏÇÒ ¼ö ÀÖ´Ù.

µ¥ÀÌŸ ¼Ò½º¸í

PEAR Çü½ÄÀÇ DSN¸¦ »ç¿ëÇÑ Á¢¼ÓÀ» Áö¿øÇÑ´Ù. À̶§ DSNÀº ´ÙÀ½°ú °°Àº Çü½ÄÀÇ Á¢¼Ó ¹®ÀÚ¿­ÀÌ µÈ´Ù:

$dsn = "$driver://$username:$password@$hostname/$databasename";

DNSÀ» Á¤Àû Å©·¡½º ÇÔ¼ö DB::Connect¿¡ Àü´ÞÇÑ´Ù. ¿¹:

   include_once('../adodb/adodb-pear.inc.php');
   $username = 'root';
   $password = '';
   $hostname = 'localhost';
   $databasename = 'xphplens';
   $driver = 'mysql';
   $dsn = "$driver://$username:$password@$hostname/$databasename";
   $db = DB::Connect($dsn);
$rs = $db->Execute('select firstname,lastname from adoxyz'); $cnt = 0; while ($arr = $rs->FetchRow()) { print_r($arr); print "<br>"; }

ÀÌ °ÍÀº PEAR°¡ ¼³Ä¡µÇ¾î ÀÖ¾î¾ß Çϸç php.iniÀÇ ±âº» Include °æ·Î¿¡ ¼³Ä¡µÈ PEAR°¡ Æ÷ÇԵǾî ÀÖ¾î¾ß ÇÑ´Ù.

·¹ÄÚµå¼ÂÀÇ Ä³½Ì

ADOdb´Â CacheExecute( ), CachePageExecute( )¿Í CacheSelectLimit( )¸¦ »ç¿ëÇؼ­ ·¹ÄÚµå¼ÂÀÇ Ä³½¬¸¦ Áö¿øÇÑ´Ù. ÀÌ °ÍÀº ij½¬µÇÁö¾Ê´Â ÇÔ¼ö¿Í À¯»çÇÏÁö¸¸ »õ·Î¿î ¸Å°³º¯¼ö, $secs2cache¸¦ ÃëÇÑ´Ù´Â Â÷ÀÌÁ¡ÀÌ ÀÖ´Ù.

¿¹:

include('adodb.inc.php'); # ADOdbÀÇ °øÅë ÄÚµå Àбâ
$ADODB_CACHE_DIR = '/usr/ADODB_cache';
$conn = &ADONewConnection('mysql');  # Á¢¼Ó »ý¼º
$conn->PConnect('localhost','userid','','agora');# MySQL, agora DB¿¡ ¿¬°á
$sql = 'select CustomerName, CustomerID from customers';
$rs = $conn->CacheExecute(15,$sql);

ù¹ø° ¸Å°³º¯¼ö´Â Äõ¸®¸¦ ij½¬ÇÒ ½Ã°£À¸·Î ´ÜÀ§´Â ÃÊÀÌ´Ù. ÀÌ Äõ¸®¸¦ ¿¬¼ÓÇؼ­ È£ÃâÇϸé $ADODB_CACHE_DIR¿¡ ÀúÀåµÈ ·¹ÄÚµå¼Â(ij½¬µÈ)ÀÌ »ç¿ëµÈ´Ù. °­Á¦·Î ij½¬¸¦ ºñ¿ì°í Äõ¸®¸¦ ½ÇÇàÇϱâÀ§ÇØ CacheExecute()ÀÇ Ã¹¹ø° ¸Å°³º¯¼ö¸¦ 0À¸·Î ¼³Á¤ÇÏ°í È£ÃâÇÒ ¼ö ÀÖ´Ù. ¶Ç ´Ù¸¥ ¹æ¹ýÀ¸·Î CacheFlush($sql)¸¦ È£ÃâÇÒ ¼ö ÀÖ´Ù.

$ADODB_CACHE_DIR¸¦ »ç¿ëÇÏ´Â °æ¿ì º¸¾ÈÀ» À§ÇØ php.iniÀÇ register_globals=off¸¦ ¼³Á¤ÇÒ °ÍÀ» ±Ç°íÇÑ´Ù.

ADOdb 1.80 ÀÌ»óÀÇ °æ¿ì CacheSelectLimit()¿Í CacheExecute()¿¡¼­ secs2cache ¸Å°³º¯¼ö´Â ¿É¼ÇÀÌ´Ù. ¸¸¾à ÀÌ °ªÀ» ¼³Á¤ÇÏÁö ¾ÊÀ¸¸é $connection->cacheSecs ¸Å°³º¯¼ö¸¦ »ç¿ëÇÑ´Ù(±âº»°ªÀº 60ºÐÀÌ´Ù).

	$conn->Connect(...);
	$conn->cacheSecs = 3600*24; # 24½Ã°£µ¿¾È ij½¬
	$rs = $conn->CacheExecute('select * from table');

magic_quotes_runtimeÀÌ off À̾î¾ß ÇÑ´Ù´Â °Í¿¡ ÁÖÀÇÇϱ⠹ٶõ´Ù. ÀÚ¼¼È÷.

Çǹþ Å×À̺í

ADOdb 2.30 ÀÌ»óÀº ±³Â÷ Å×À̺í·Î ¾Ë·ÁÁø Çǹþ Å×À̺íÀ» »ý¼ºÇÏ´Â SQL ¹®À» »ý¼ºÇÒ ¼ö ÀÖ´Ù. º¸´Ù ÀÚ¼¼ÇÑ ¼³¸íÀº DevShedÀÇ ±³Â÷ Å×ÀÌºí ±æÀâÀ̸¦ Àб⠹ٶõ´Ù. µ¥ÀÌŸ º£À̽º°¡ CASE-WHEN ¹®À» Áö¿øÇÏ´Â °ÍÀ¸·Î °¡Á¤Çß´Ù.

ÀÌ ¿¹¿¡¼­ MicrosoftÀÇ Northwind DB¸¦ »ç¿ëÇÒ °ÍÀÌ´Ù. ÀÌ DB´Â Á¦Ç° Å×À̺íÀ» °¡Áö°í ÀÖ°í ÀÌ Å×À̺íÀ» °ø±ÞÀÚ´ë Á¦Ç° ºÐ·ù·Î ºÐ¼®ÇÏ±æ ¿øÇÑ´Ù°í ÇÏÀÚ. °¢Çà¿¡ °ø±ÞÀÚ¸¦ µÎ°í ºÐ·ù»ó¿¡ ÇǹþÀ» µÎ´Â °ÍÀ¸·Î ÇÏ°Ú´Ù. µû¶ó¼­ ÁÂÃøÀÇ Å×À̺í·ÎºÎÅÍ ¿ìÃøÀÇ Çǹþ Å×À̺í·Î »ý¼ºµÈ´Ù:

°ø±ÞÀÚ ºÐ·ù
°ø±ÞÀÚ1 ºÐ·ù1
°ø±ÞÀÚ2 ºÐ·ù1
°ø±ÞÀÚ2 ºÐ·ù2
-->
  ºÐ·ù1 ºÐ·ù2 ÃÑ
°ø±ÞÀÚ1 1 0 1
°ø±ÞÀÚ2 1 1 2

´ÙÀ½ ÄÚµå´Â ±³Â÷ Å×À̺íÀ» »ý¼ºÇϴµ¥ »ç¿ëµÉ SQLÀ» »ý¼ºÇÒ °ÍÀÌ´Ù:

# ¸ÞÀÏ "products" Å×ÀÌºí¿¡ ÁúÀÇ
# ÇàÀ» CompanyNameÀ¸·Î ¼³Á¤
# Ä÷³À» CategoriesÀÇ °ªÀ¸·Î ¼³Á¤
# "categories"°ú "suppliers"¸¦ Á¶È¸ÇϱâÀ§ÇÏ ¸µÅ©¿¡´ëÇÑ JoinÀ» Á¤ÀÇ
#
 include "adodb/pivottable.php";
 $sql = PivotTableSQL(
 	$gDB,                                      # adodb Á¢¼Ó
 	'products p ,categories c ,suppliers s',   # Å×À̺í
	'CompanyName',                             # Çà(´ÙÁß Çʵ嵵 Çã¿ëµÊ)
	'CategoryName',                            # ÇǹþÇÒ Ä÷³
	'p.CategoryID = c.CategoryID and s.SupplierID= p.SupplierID' # joins/where
);

ÀÌ °ÍÀº ´ÙÀ½°ú °°Àº SQLÀ» »ý¼ºÇÏ°Ô µÈ´Ù:

SELECT CompanyName,
SUM(CASE WHEN CategoryName='Beverages' THEN 1 ELSE 0 END) AS "Beverages",
SUM(CASE WHEN CategoryName='Condiments' THEN 1 ELSE 0 END) AS "Condiments",
SUM(CASE WHEN CategoryName='Confections' THEN 1 ELSE 0 END) AS "Confections",
SUM(CASE WHEN CategoryName='Dairy Products' THEN 1 ELSE 0 END) AS "Dairy Products",
SUM(CASE WHEN CategoryName='Grains/Cereals' THEN 1 ELSE 0 END) AS "Grains/Cereals",
SUM(CASE WHEN CategoryName='Meat/Poultry' THEN 1 ELSE 0 END) AS "Meat/Poultry",
SUM(CASE WHEN CategoryName='Produce' THEN 1 ELSE 0 END) AS "Produce",
SUM(CASE WHEN CategoryName='Seafood' THEN 1 ELSE 0 END) AS "Seafood",
SUM(1) as Total
FROM products p ,categories c ,suppliers s WHERE p.CategoryID = c.CategoryID and s.SupplierID= p.SupplierID
GROUP BY CompanyName

¹üÀ§¸¦ »ç¿ëÇÔÀ¸·Î¼­ ¼ýÀÚ Ä÷³°ú Çհ踦 ÇǹþÇÒ ¼ö ÀÖ´Ù. ÀÌ ÄÚµå´Â ADOdb 2.41¿¡¼­ °³¹ßµÇ¾úÀ¸¸ç ÇÏÀ§È£È¯¼ºÀº ¾ø´Ù. µÎ¹ø° ¿¹´Â ´ÙÀ½°ú °°´Ù:

 $sql = PivotTableSQL(
 	$gDB,                                       # adodb Á¢¼Ó
 	'products p ,categories c ,suppliers s',    # Å×À̺í
	'CompanyName',                              # Çà(´ÙÁß Çʵ嵵 Çã¿ëµÊ)
   array(                                       # ÄÄ·³ ¹üÀ§
	' 0 '      => 'UnitsInStock <= 0',
	"1 to 5"   => '0 < UnitsInStock and UnitsInStock <= 5',
	"6 to 10"  => '5 < UnitsInStock and UnitsInStock <= 10',
	"11 to 15" => '10 < UnitsInStock and UnitsInStock <= 15',
	"16+"      => '15 < UnitsInStock'
	),
	' p.CategoryID = c.CategoryID and s.SupplierID= p.SupplierID', # joins/where
	'UnitsInStock',                             # Çʵå ÇÕ
	'Sum '                                      # ÇÕ°è ¶óº§ÀÇ Á¢µÎ¾î
);

ÀÌ °ÍÀº ´ÙÀ½°ú °°Àº SQLÀ» »ý¼ºÇÑ´Ù:

SELECT CompanyName,
SUM(CASE WHEN UnitsInStock <= 0 THEN UnitsInStock ELSE 0 END) AS "Sum 0 ",
SUM(CASE WHEN 0 < UnitsInStock and UnitsInStock <= 5 THEN UnitsInStock ELSE 0 END) AS "Sum 1 to 5",
SUM(CASE WHEN 5 < UnitsInStock and UnitsInStock <= 10 THEN UnitsInStock ELSE 0 END) AS "Sum 6 to 10",
SUM(CASE WHEN 10 < UnitsInStock and UnitsInStock <= 15 THEN UnitsInStock ELSE 0 END) AS "Sum 11 to 15",
SUM(CASE WHEN 15 < UnitsInStock THEN UnitsInStock ELSE 0 END) AS "Sum 16+",
SUM(UnitsInStock) AS "Sum UnitsInStock",
SUM(1) as Total,
FROM products p ,categories c ,suppliers s WHERE p.CategoryID = c.CategoryID and s.SupplierID= p.SupplierID
GROUP BY CompanyName


Å©·¡½º ÂüÁ¶

[ ]·Î Ç¥½ÃµÈ ¸Å°³º¯¼ö´Â ¿É¼ÇÀÌ´Ù.

Àü¿ª º¯¼ö

$ADODB_COUNTRECS

µ¥ÀÌŸº£À̽º µå¶óÀ̹ö API°¡ ¸®ÅϵǴ ·¹ÄÚµåÀÇ ¼ö(SELECT ¹®)¸¦ °è»êÇÏ´Â ±â´ÉÀ» Áö¿øÇÏÁö ¾Ê´Â´Ù¸é RecordCount() ÇÔ¼ö´Â Àü¿ªº¯¼ö $ADODB_COUNTRECS°¡ ÂüÀ¸·Î ¼³Á¤(±âº»°ª)µÇ¾úÀ» ¶§ ¿¡¹Ä·¹À̼ÇÀ» ¼öÇàÇÑ´Ù. ¿¡¹Ä·¹À̼ÇÀº ·¹Äڵ带 ¹öÆ㸵ÇÔÀ¸·Î¼­ ¼öÇàµÈ´Ù. µû¶ó¼­ ·¹ÄÚµå¼ÂÀÌ Å« °æ¿ì ¸¹Àº ¾çÀÇ ¸Þ¸ð¸®°¡ »ç¿ëµÉ ¼ö ÀÖ´Ù. ÃÖÀûÀÇ ¼º´ÉÀ» À§ÇØ ÀÌ º¯¼ö¸¦ °ÅÁþÀ¸·Î ¼³Á¤Çϱ⠹ٶõ´Ù. ÀÌ º¯¼ö´Â ÁúÀÇ°¡ ¼öÇàµÉ ¶§ ¸¶´Ù °Ë»çµÈ´Ù. µû¶ó¼­ ·¹ÄÚ¼ÂÀÇ Ä«¿îÆ®¸¦ ¼±ÅÃÀûÀ¸·Î »ç¿ëÇÒ ¼ö ÀÖ´Ù.

$ADODB_CACHE_DIR

·¹ÄÚµå¼Â ij½¬¸¦ »ç¿ëÇÑ´Ù¸é, ÀÌ °ªÀº ·¹ÄÚµå¼ÂÀÌ ÀúÀåµÉ µð·ºÅ丮ÀÌ´Ù. ÀÌ Æ¯Â¡À» »ç¿ëÇÑ´Ù¸é º¸¾È»ó php.ini¿¡¼­ register_globals=off·Î ¼³Á¤ÇÒ °ÍÀ» ±Ç°íÇÑ´Ù.

Unix¿Í ¾ÆÆÄÄ¡¸¦ »ç¿ëÇÑ´Ù¸é ´ÙÀ½Ã³·³ ij½¬ µð·ºÅ丮ÀÇ ±ÇÇÑÀ» ¸ðµç »ç¶÷ÀÌ Á¢±ÙÇÒ ¼ö ÀÖµµ·Ï º¯°æÇÒ ÇÊ¿ä°¡ ÀÖ´Ù:

chown -R apache /path/to/adodb/cache
chgrp -R apache /path/to/adodb/cache

$ADODB_ANSI_PADDING_OFF

¿Ã¹Ù¸¥ trim CHAR Çʵå(ibase/firebirdÀÇ °æ¿ì VARCHAR)¸¦ °áÁ¤ÇÑ´Ù. trim½Ã ÂüÀ¸·Î ¼³Á¤ÇÑ´Ù. ±âº»°ªÀº °ÅÁþÀÌ´Ù. ÇöÀç oci8pro, ibase¿Í firebird µå¶óÀ̹ö¿¡¼­ µ¿ÀÛÇÑ´Ù. ADOdb 4.01¿¡¼­ Ãß°¡ µÇ¾ú´Ù.

$ADODB_LANG

MetaErrorMsg()¿¡¼­ »ç¿ëµÇ´Â ¾ð¾î¸¦ °áÁ¤ÇÑ´Ù. ±âº»°ªÀº 'en(¿µ¾î)'ÀÌ´Ù. Áö¿øµÇ´Â ¾ð¾î¸¦ ¾Ë±âÀ§Çؼ­´Â adodb/lang/adodb-$lang.inc.php ÆÄÀÏÀ» ã¾Æº¸±â ¹Ù¶õ´Ù. ¿©±â¼­ $lang´Â Áö¿øµÇ´Â ¾ð¾îÀÌ´Ù.

$ADODB_FETCH_MODE

ÀÌ °ªÀº ·¹ÄÚµå¼ÂÀ» ¾î¶² Á¾·ùÀÇ ¹è¿­À» »ç¿ëÇؼ­ º¹¿øÇÒ °ÍÀÎÁö¸¦ °áÁ¤ÇÏ´Â Àü¿ªº¯¼öÀÌ´Ù. ·¹ÄÚµå¼ÂÀº »ý¼º(¿¹. Execute( ) ¶Ç´Â SelectLimit( ))½Ã ÀÌ °ª¿¡µû¶ó ÀúÀåµÈ´Ù. À̾ $ADODB_FETCH_MODE¸¦ º¯°æÇصµ ±âÁ¸ÀÇ ·¹ÄÚµå¼Â¿¡´Â ¿µÇâÀ» ÁÖÁö¸øÇϸç, ¿À·ÎÁö »õ·Î »ý¼ºµÈ ·¹ÄÚµå¼Â¿¡¸¸ ¿µÇâÀ» ¹ÌÄ£´Ù.

´ÙÀ½ »ó¼ö°¡ Á¤ÀǵǾú´Ù:

define('ADODB_FETCH_DEFAULT',0);
define('ADODB_FETCH_NUM',1);
define('ADODB_FETCH_ASSOC',2);
define('ADODB_FETCH_BOTH',3);

¿¹:

	$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
	$rs1 = $db->Execute('select * from table');
	$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
	$rs2 = $db->Execute('select * from table');
	print_r($rs1->fields); # array([0]=>'v0',[1] =>'v1')·Î Ãâ·Â
	print_r($rs2->fields); # array(['col1']=>'v0',['col2'] =>'v1')·Î Ãâ·Â

À§ÀÇ ¿¹¿¡¼­ ¾Ë¼ö ÀÖ´Â °Íó·³ ·¹ÄÚµå¼ÂÀº Execute()¿¡ÀÇÇØ »ý¼ºµÉ ¶§ ¼³Á¤µÈ $ADODB_FETCH_MODE¿¡µû¶ó ¼­·Î ´Ù¸¥ ¸ðµå·Î ÀúÀå/»ç¿ëµÉ ¼ö ÀÖ´Ù.

ÆäÄ¡ ¸ðµå°¡ ¹Ì¸® Á¤ÀǵÇÁö ¾ÊÀ¸¸é ÆäÄ¡ ¸ðµå´Â ADODB_FETCH_DEFAULT·Î ¼³Á¤µÈ´Ù. ±âº» ¸ðµåÀÇ µ¿ÀÛÀº µå¶óÀ̹ö¿¡µû¶ó ´Ù¸£¸ç ADODB_FETCH_DEFAULT¿¡ ÀÇÁ¸ÇÏÁö ¾Ê´Â´Ù. ½ºÅ©¸³Æ® ȣȯ¼ºÀ» À§ÇØ ADODB_FETCH_NUMÀ̳ª ADODB_FETCH_ASSOC¸¦ °í¼öÇÒ °ÍÀ» ±Ç°íÇÑ´Ù. ¸¹Àº µå¶óÀ̹ö´Â ADODB_FETCH_BOTH¸¦ Áö¿øÇÏÁö ¾Ê´Â´Ù.

SetFetchMode ÇÔ¼ö

¸î¸î ÇÁ·Î±×·¡¸Ó´Â º¸´Ù °³Ã¼ ÁöÇâÀûÀÎ ¹æ¹ýÀ» »ç¿ëÇϱæ ÁÁ¾ÆÇÑ´Ù. ÆäÄ¡ ¸ðµå ¿ª½Ã °³Ã¼ ÇÔ¼ö, SetFetchMode¿¡ÀÇÇØ ¼³Á¤µÉ ¼ö ÀÖ´Ù. ÀÏ´Ü ÀÌ ÇÔ¼ö°¡ Á¢¼Ó °³Ã¼¿¡´ëÇØ È£ÃâµÇ¸é Á¢¼Ó °³Ã¼´Â Àü¿ªº¯¼ö $ADODB_FETCH_MODE¸¦ ¹«½ÃÇÏ°í ³»ºÎÀÇ fetchMode ¼Ó¼ºÀ» ÂüÁ¶ÇϱâµÈ´Ù.

	$db->SetFetchMode(ADODB_FETCH_NUM);
	$rs1 = $db->Execute('select * from table');
	$db->SetFetchMode(ADODB_FETCH_ASSOC);
	$rs2 = $db->Execute('select * from table');
	print_r($rs1->fields); # array([0]=>'v0',[1] =>'v1')¸¦ Ãâ·Â
	print_r($rs2->fields); # array(['col1']=>'v0',['col2'] =>'v1')¸¦ Ãâ·Â

ÀÌÀü ÆÐÄ¡ ¸ðµå¸¦ º¹¿øÇϱâ À§ÇØ $db->fetchMode ¼Ó¼ºÀ» °Ë»çÇϰųª SetFetchMode( )ÀÇ ¸®ÅÏ°ªÀ» »ç¿ëÇÒ ¼ö ÀÖ´Ù.

ADODB_ASSOC_CASE

¼­·Î ´Ù¸£°Ô µ¿ÀÛÇÏ´Â ÀÓÀÇÀÇ µå¶óÀ̹ö¿¡¼­ ¿¬°ü¹è¿­ÀÇ ´ë¼Ò¹®ÀÚ¸¦ Á¦¾îÇÒ ¼ö ÀÖ´Ù. sybase, oci8po, mssql, odbc, ibase µå¶óÀ̹ö¿Í À̵é·ÎºÎÅÍ À¯µµµÈ ¸ðµç µå¶óÀ̹ö´Â ±âº»ÀûÀ¸·Î Å°(Çʵå¸í)°¡ ¼Ò¹®ÀÚÀÎ ·¹ÄÚµå¼ÂÀ» »ý¼ºÇÑ´Ù. ADODB_ASSOC_CASE »ó¼ö¸¦ »ç¿ëÇÔÀ¸·Î¼­ ÀÌ Å°ÀÇ ´ë¼Ò¹®ÀÚ¸¦ º¯°æÇÒ ¼ö ÀÖ´Ù. ´ÙÀ½Àº °¡´ÉÇÑ ¼¼°¡Áö °ªÀÌ´Ù:

0 = ¼Ò¹®ÀÚ Çʵå¸í. $rs->fields['orderid']
1 = ´ë¹®ÀÚ Çʵå¸í. $rs->fields['ORDERID']
2 = DB °íÀ¯ÀÇ Çʵå¸í. $rs->fields['OrderID'] -- ADOdb 2.90 ÀÌÈÄ ÀÌ °ªÀÌ ±âº»ÀÓ

ÀÌ »ó¼ö¸¦ »ç¿ëÇϱâÀ§ÇØ adodb.inc.php¸¦ IncludeÇϱâ Àü¿¡ ¸ÕÀú ¼±¾ðÇØ¾ß ÇÑ´Ù.

define('ADODB_ASSOC_CASE', 2); # ADODB_FETCH_ASSOC¿¡ DB °íÀ¯ÀÇ Çʵå¸í »ç¿ë
include('adodb.inc.php');


ADOConnection

µ¥ÀÌŸº£À̽º ¿¬°á, SQL ¹® ½ÇÇà, ¹®ÀÚ¿­ ¿¬°á°ú ³¯Â¥ Çü½Äó·³ SQL ¹®À» ÀÏ¹Ý Çü½ÄÀ¸·Î º¯È¯ÇÏ´Â À¯Æ¿¸®Æ¼ ÇÔ¼ö ÁýÇÕÀ» °¡Áø °³Ã¼.

ADOConnection Çʵå

databaseType: ¿¬°áÇÏ·Á´Â DB ½Ã½ºÅÛÀÇ À̸§. ¿¹. odbc, mssql, mysql.

dataProvider: DB Á¢¼Ó¿¡ »ç¿ëµÇ´Â ±âÃÊ ¸ÞÄ«´ÏÁò. º¸Åë native·Î ¼³Á¤µÊ. ¿¹¿Ü: odbc³ª ado

host: ¿¬°áÇÒ ¼­¹ö À̸§À̳ª µ¥ÀÌŸ ¼Ò½º¸í(DSN).

database: ¿¬°áÇÒ µ¥ÀÌŸº£À̽ºÀÇ À̸§. ado°¡ »ç¿ëµÇ¸é ado µ¥ÀÌŸ Á¦°øÀÚ¸¦ À¯ÁöÇÑ´Ù.

user: ¿¬°áÇÒ µ¥ÀÌŸº£À̽ºÀÇ ·Î±×ÀÎ ID. ¾ÏÈ£´Â º¸¾È»ó ÀúÀåµÇÁö¾Ê´Â´Ù.

raiseErrorFn: ÀÌ°ÍÀ¸·Î ¿À·ù ó¸® ÇÔ¼ö¸¦ Á¤ÀÇÇÒ ¼ö ÀÖ´Ù. ¿¹´Â adodb-errorhandler.inc.php¸¦ º¸±â¹Ù¶õ´Ù.

debug: µð¹ö±× ¸ðµå¸¦ ¿øÇÏ´Â °æ¿ì true·Î ¼³Á¤ÇÑ´Ù.

concat_operator: º¸Åë '+'³ª '||'·Î ¼³Á¤. SQL¿¡¼­ ¹®ÀÚ¸¦ ¿¬°áÇÏ´Â »ç¿ëµÇ´Â ¿¬»êÀÚ. Concat ÇÔ¼ö¿¡ÀÇÇØ »ç¿ëµÊ.

fmtDate: µ¥ÀÌŸº£À̽º¿¡ ³¯Â¥¸¦ Àü¼ÛÇÒ ¶§ DBDate¿¡ÀÇÇØ »ç¿ëµÇ´Â Çü½Ä. Microsoft AccessÀÇ °æ¿ì '#Y-m-d#'À̸ç MysqlÀÇ °æ¿ì ''Y-m-d''ÀÌ´Ù.

fmtTimeStamp: µ¥ÀÌŸº£À̽º¿¡ ŸÀÓ½ºÅÆÇÁ¸¦ Àü¼ÛÇÒ ¶§ DBTimeStamp¿¡ÀÇÇØ »ç¿ëµÇ´Â Çü½Ä.

true: ÂüÀ» Ç¥ÇöÇÏ´Â »ç¿ëµÇ´Â °ª. ¿¹. FoxproÀÇ °æ¿ì '.T.', Microsoft SQLÀÇ °æ¿ì '1'.

false: °ÅÁþÀ» Ç¥ÇöÇϴµ¥ »ç¿ëµÇ´Â °ª. ¿¹. FoxproÀÇ °æ¿ì '.F.', Microsoft SQLÀÇ °æ¿ì'0'.

replaceQuote: ÀοëºÎÈ£¸¦ À̽ºÄÉÀÌÇÁÇϴµ¥ »ç¿ëµÇ´Â ¹®ÀÚ. ¿¹. Microsoft SQLÀÇ °æ¿ì Å«µû¿ÈÇ¥, ÀÛÀº µû¿ÈÇ¥, MySQLÀÇ °æ¿ì ¿ª½½·¡½¬-ÀÛÀºµû¿ÈÇ¥. qstr¿¡ÀÇÇØ »ç¿ëµÊ.

autoCommit: ÀÚµ¿ Ä¿¹ÔÀ» »ç¿ëÇÒ °ÍÀÎÁö¸¦ Áö½ÃÇÔ. ±âº»°ªÀº Âü.

charSet: »ç¿ëµÇ´Â ±âº» ¹®ÀÚÁýÇÕÀ» ¼³Á¤. ÇöÀç interbase¸¸ Áö¿ø.

dialect: »ç¿ëµÇ´Â ±âº» SQL Dialect ¼³Á¤. ÇöÀç interbase¸¸ Áö¿ø.

metaTablesSQL: µî·ÏµÈ Å×À̺íÀÇ ¸ñ·ÏÀ» ¸®ÅÏÇÏ´Â SQL¹®. ¿¹. MySQLÀÇ °æ¿ì SHOW TABLES.

genID: µ¥ÀÌŸº£À̽º¿¡¼­ Áö¿øµÇ´Â °æ¿ì GenID()¿¡ÀÇÇØ »ý¼ºµÈ °¡Àå ÃÖ½ÅÀÇ ID.

cacheSecs: CacheExecute() À̳ª CacheSelectLimit()À» $secs2cache ¸Å°³º¯¼ö¾øÀÌ ½ÇÇàÇÑ °æ¿ì ·¹ÄÚµå¼ÂÀ» ij½¬ÇÏ´Â ½Ã°£(´ÜÀ§ ÃÊ).

sysDate: ÇöÀç ³¯Â¥¸¦ °¡Á®¿À±âÀ§ÇØ È£ÃâµÇ´Â µ¥ÀÌŸº£À̽º ÇÔ¼ö(¹®ÀÚ¿­). »ðÀÔ, °»½Å½Ã À¯¿ë.

sysTimeStamp: ÇöÀçÀÇ timestamp/datetime °ªÀ» °¡Á®¿Ã¶§ È£ÃâµÇ´Â µ¥ÀÌŸº£À̽º ÇÔ¼ö(¹®ÀÚ¿­).

leftOuter: ¾Ë·ÁÁø °æ¿ì, Left Outter Join¿¡´ëÇÑ ¿¬»êÀÚ¸¦ °¡Áö°í ÀÖ´Â ¹®ÀÚ¿­. ±×·¸Áö ¾ÊÀ¸¸é °ÅÁþÀ¸·Î ¼³Á¤µÊ.

rightOuter: ¾Ë·ÁÁø °æ¿ì, Right Outter Join¿¡´ëÇÑ ¿¬»êÀÚ¸¦ °¡Áö°í ÀÖ´Â ¹®ÀÚ¿­. ±×·¸Áö ¾ÊÀº °æ¿ì °ÅÁþÀ¸·Î ¼³Á¤µÊ.

ansiOuter: ºÎ¿ï. ANSI Çü½ÄÀÇ Outter JoinÀÌ Çã¿ëµÇ´Â °æ¿ì Âü. ¿¹: select * from table1 left join table2 on p1=p2.

connectSID: oci8 µå¶óÀ̹ö¿¡¼­ Á¢¼Ó½Ã $database ¸Å°³º¯¼ö¸¦ SID·Î ó¸®ÇÒ °ÍÀÎÁö ¾Æ´ÑÁö¸¦ Áö½ÃÇÏ´Â ºÎ¿ï°ª. Oracle 8.0.5 ÀÌÇÏÀÇ ¹öÀü¿¡¼­ À¯¿ë.

autoRollback: ÀÌ °ªÀÌ ÂüÀ¸·Î ¼³Á¤µÇ¸é PConnect( )¸¦ ÀÌ¿ëÇÑ ¿µ±¸ Á¢¼ÓÀº ÀÚµ¿ ·Ñ¹éµÈ´Ù. ±âº»°ªÀº °ÅÁþ.


ADOConnection ÁÖ ÇÔ¼ö

ADOConnection( )

»ý¼ºÀÚ. Á÷Á¢ È£ÃâÇÒ ¼ö ¾ø´Ù. ADONewConnection( )À» »ç¿ëÇÑ´Ù.

Connect($host,[$user],[$password],[$database])

µ¥ÀÌŸ ¼Ò½º³ª ¼­¹ö($host)¿¡ »ç¿ëÀÚ ID($user)¿Í ¾ÏÈ£($password)·Î ÀϽà Á¢¼ÓÇÑ´Ù. ¼­¹ö°¡ ´ÙÁß µ¥ÀÌŸº£À̽º¸¦ Áö¿øÇÏ´Â °æ¿ì $database·Î µ¥ÀÌŸº£À̽º¿¡ Á¢¼ÓÇÒ ¼ö ÀÖ´Ù.

Á¢¼Ó ¼º°ø ¿©ºÎ¿¡µû¶ó Âü/°ÅÁþÀ» ¸®ÅÏÇÑ´Ù.

ADO ÁÖÀÇ: OLEDB°¡ ¾Æ´Ï¶ó Microsoft ADO¸¦ »ç¿ëÇÏ´Â °æ¿ì »ç¿ëÁßÀÎ OLEDB µ¥ÀÌŸ Á¦°øÀÚ·Î $database ¸Å°³º¯¼ö¸¦ ¼³Á¤ÇÒ ¼ö ÀÖ´Ù.

PostgreSQL: µ¥ÀÌŸº£À̽º¿¡ Á¢¼ÓÇÏ´Â ¶Ç ´Ù¸¥ ¹æ¹ýÀº ù¹ø° ¸Å°³º¯¼ö $host¿¡ Ç¥ÁØ PostgreSQL Á¢¼Ó ¹®ÀÚ¿­À» ÁöÁ¤ÇÏ´Â °ÍÀÌ´Ù. ÀÌ °æ¿ì ´Ù¸¥ ¸Å°³º¯¼ö´Â ¹«½ÃµÈ´Ù.

Oracle°ú Oci8ÀÇ °æ¿ì µÎ°¡Áö Á¢¼Ó¹æ¹ýÀÌ Á¦°øµÈ´Ù. ù¹ø°·Î tnsnames.ora(¶Ç´Â ONAMES³ª HOSTNAMES)¿¡ Á¤ÀÇµÈ TNS ¸íÀ» »ç¿ëÇÏ´Â °ÍÀÌ´Ù. $database Çʵ忡 TNS ¸íÀ» µÎ°í $host Çʵ带 °ÅÁþÀ¸·Î ¼³Á¤ÇÑ´Ù. ¶Ç´Ù¸¥ ¹æ¹ýÀº $host¿¡ ¼­¹ö¸¦ ¼³Á¤ÇÏ°í, $database¿¡ µ¥ÀÌŸº£À̽º SID¸¦ ¼³Á¤ÇÑ´Ù. ÀÌ ¹æ¹ýÀ» »ç¿ëÇϸé tsnnames.ora¸¦ ¿ìȸÇϰԵȴÙ.

¿¹:

 # tnsnames.ora/ONAMES/HOSTNAMESÀÇ $oraname
 $conn->Connect(false, 'scott', 'tiger', $oraname); 
 $conn->Connect('server:1521', 'scott', 'tiger', 'ServiceName'); # tnsnames.ora¸¦ ¿ìȸÇÔ

php.weblogs.com/ADOdb¿Í ÀÌ ¹èÆ÷º»¿¡ Æ÷ÇÔµÈ testdatabases.inc.php¿¡ µ¥ÀÌŸº£À̽º¿¡ Á¢¼ÓÇÏ´Â ¸¹Àº ¿¹°¡ ÀÖ´Ù.

PConnect($host,[$user],[$password],[$database])

µ¥ÀÌŸ ¼Ò½º³ª ¼­¹ö($host)¿¡ »ç¿ëÀÚ ID($user)¿Í ¾ÏÈ£($password)·Î ¿µ±¸ Á¢¼ÓÇÑ´Ù. ¼­¹ö°¡ ´ÙÁß µ¥ÀÌŸº£À̽º¸¦ Áö¿øÇÏ´Â °æ¿ì $database·Î µ¥ÀÌŸº£À̽º¿¡ Á¢¼ÓÇÒ ¼ö ÀÖ´Ù.

PHP ¸Å´º¾ó¿¡¼­ ¾ð±ÞÇÑ °Íó·³ ADOdb 2.21 ÀÌÈÄ ¹öÀü¿¡¼­´Â ¼±ÅÃµÈ µ¥ÀÌŸº£À̽º¿¡ ¿µ±¸Á¢¼ÓÇÏ´Â °æ¿ì ·Ñ¹éÀ» ¼öÇàÇÑ´Ù. ¿µÇâÀ» ¹Þ´Â µ¥ÀÌŸº£À̽º´Â º¯°æ ±â·ÏÀ̳ª ¼Ò½º Äڵ带 º¸±â ¹Ù¶õ´Ù.

Á¢¼Ó ¼º°ø ¿©ºÎ¿¡µû¶ó Âü/°ÅÁþÀ» ¸®ÅÏÇÑ´Ù. º¸´Ù ÀÚ¼¼ÇÑ Á¤º¸´Â À§ÀÇ Connect( )¸¦ º¸±â ¹Ù¶õ´Ù.

ADOdb 2.21 ÀÌÈÄ ¹öÀü¿¡¼­´Â ÀÚµ¿ ·Ñ¹éÀ» Áö¿øÇÑ´Ù. ¿¹:

 $conn = &NewADOConnection('mysql');
 $conn->autoRollback = true; # ±âº»°ªÀº °ÅÁþ
 $conn->PConnect(...); # ·Ñ¹éÀÌ ¼öÇàµÊ

PConnect( )·Î ¿µ±¸ Á¢¼ÓÇÒ ¶§ ADOdb´Â ¸ÕÀú ·Ñ¹éÀ» ¼öÇàÇÑ´Ù. ÀÌ °ÍÀº PHP´Â ¿µ±¸ Á¢¼ÓÀÌ »ç¿ëµÉ ¶§ ±âÁ¸ÀÇ ½ÇÆÐÇÑ Æ®·£Àè¼Ç¿¡´ëÇØ ·Ñ¹éÀ» º¸ÀåÇÏÁö¾Ê´Â´Ù°í PHP ¹®¼­¿¡ ³ª¿ÍÀֱ⶧¹®ÀÌ´Ù. ÀÌ ±â´ÉÀº ÇöÀç Oracle, MySQL, PgSQL, MSSQL, ODBC¿¡¼­ ±¸ÇöµÇ¾ú´Ù.

ADOdb 3.11 ÀÌ·¡ PConnect¸¦ È£ÃâÇϱâÀü¿¡ ADODB_NEVER_PERSIST »ó¼ö¸¦ Á¤ÀÇÇؼ­ PConnect¸¦ È£ÃâÇÒ Áö¶óµµ °­Á¦·Î ÀϽà Á¢¼ÓÀ¸·Î Á¢¼ÓÇÒ ¼ö ÀÖ´Ù.

NConnect($host,[$user],[$password],[$database])

°­Á¦·Î »õ·Î¿î Á¢¼ÓÀ» ¸¸µç´Ù. PHP´Â ¶§¶§·Î Connect()³ª PConnect()¸¦ »ç¿ëÇÒ ¶§ ±âÁ¸ Á¢¼ÓÀ» ´Ù½Ã »ç¿ëÇÑ´Ù. ÇöÀç MySQL(PHP 4.3.0 ÀÌ»ó), PostgreSQL, oci8¿¡¼­ À¯µµµÈ µå¶óÀ̹ö¿¡¼­¸¸ µ¿ÀÛÇÑ´Ù. ´Ù¸¥ µå¶óÀ̹ö¿¡¼­ NConnect( )´Â Connect( )¿Í µ¿ÀÏÇÏ°Ô µ¿ÀÛÇÑ´Ù.

Execute($sql,$inputarr=false)

SQL ¹®, $sql¸¦ ½ÇÇàÇÏ°í ¼º°øÀûÀÎ °æ¿ì À¯µµµÈ ADORecordSet Å©·¡½º¸¦ ¸®ÅÏÇÑ´Ù. ºñ·Ï Insert¿Í Update¹®ÀÌ ¼öÇàµÈ °æ¿ì¶óµµ ¼º°øÇÑ °æ¿ì ·¹ÄÚµå¼ÂÀº Ç×»ó ¸®ÅϵȴÙ. ¶ÇÇÑ Prepare()·Î Áغñ(ÄÄÆÄÀÏ)µÈ $sql ¹®À» Àü´Þ ÇÒ ¼ö ÀÖ´Ù.

À¯µµµÈ ADORecordSet Å©·¡½º¸¦ ¸®ÅÏ. ¿¹. MySQLÀ» ÅëÇØ Á¢¼ÓÇÑ °æ¿ì, ADORecordSet_mysqlÀÌ ¸®ÅϵȴÙ. SQL ¹®À» ½ÇÇàÇÏ´ÂÁß ¿À·ù°¡ ¹ß»ýÇÑ °æ¿ì °ÅÁþÀÌ ¸®ÅϵȴÙ.

$inputarr ¸Å°³º¯¼ö´Â ¸Å°³º¯¼ö¿Í º¯¼ö¸¦ ¹ÙÀεùÇϴµ¥ »ç¿ëµÉ ¼ö ÀÖ´Ù. ´ÙÀ½Àº OracleÀÇ ¿¹ÀÌ´Ù:

 $conn->Execute("SELECT * FROM TABLE WHERE COND=:val", array('val'=> $val));
 

? °ü·Ê¸¦ »ç¿ëÇÑ ¶Ç´Ù¸¥ ¿¹(ODBC °æ¿ì):

  $conn->Execute("SELECT * FROM TABLE WHERE COND=?", array($val));
º¯¼ö ¹ÙÀεù

º¯¼ö ¹ÙÀεùÀº SQL ¹®À» ÄÄÆÄÀÏÇÏ°í ij½¬ÇÏ´Â ¼Óµµ¸¦ ³ô¿©ÁÖ¸ç, °á°úÀûÀ¸·Î º¸´Ù ³ôÀº ¼º´ÉÀ» ±â´ëÇÒ ¼ö ÀÖ´Ù. ÇöÀç Oracle, Inetbase¿Í ODBC°¡ º¯¼ö ¹ÙÀεùÀ» Áö¿øÇÑ´Ù. Interbase/ODBC Çü½ÄÀÇ ?ÀÌ ¹ÙÀεùÀ» Áö¿øÇÏÁö ¾Ê´Â µ¥ÀÌŸº£À̽º¿¡¼­ ¹ÙÀεùÀ» Èä³»³»±âÀ§ÇØ »ç¿ëµÈ´Ù.

ODBC, Interbase, oci8po µå¶óÀ̹ö¿¡¼­ º¯¼ö ¹ÙÀεù.

$rs = $db->Execute('select * from table where val=?', array('10'));
oci8 µå¶óÀ̹ö¿¡¼­ º¯¼ö ¹ÙÀεù:
$rs = $db->Execute('select name from table where val=:key', 
  array('key' => 10));
¹úÅ© ¹ÙÀεù

ADOdb 3.80 ÀÌ·¡·Î ADOdb´Â Execute( )¿¡¼­ ¹úÅ© ¹ÙÀεùÀ» Áö¿øÇÑ´Ù. ¹úÅ© ¹ÙÀεùÀº INSERT/UPDATE³ª DELETE ¹®¿¡ ¹Ù¿îµåµÉ 2Â÷¿ø ¹è¿­À» Àü´ÞÇÏ´Â °ÍÀÌ´Ù.

$arr = array(
	array('Ahmad',32),
	array('Zulkifli', 24),
	array('Rosnah', 21)
	);
$ok = $db->Execute('insert into table (name,age) values (?,?)',$arr);

ÀÌ °ÍÀº SQL¹®ÀÌ ¸ÕÀú ¸¸µé¾îÁö±â¶§¹®¿¡ ¾ÆÁÖ ³ôÀº ¼º´ÉÀ» Á¦°øÇÑ´Ù. ÁغñµÈ ¹®ÀåÀº °¢ ¹è¿­¿¡´ëÇØ ¹Ýº¹ÀûÀ¸·Î ¼öÇàµÈ´Ù. ¸ðµç ÇàÀÌ ½ÇÇàµÇ°Å³ª ù¹ø° ¿À·ù°¡ ¹ß»ýÇÏ¸é ½ÇÇàÀÌ ÁߴܵȴÙ. ÀÌ °ÍÀº ¸¹Àº ·®ÀÇ µ¥ÀÌŸ¸¦ °¡Á®¿À´Âµ¥ ¾ÆÁÖ À¯¿ëÇÏ´Ù.

CacheExecute([$secs2cache,]$sql,$inputarr=false)

Execute¿Í ºñ½ÁÇÏÁö¸¸ ·¹ÄÚµå¼ÂÀÌ $ADODB_CACHE_DIR µð·ºÅ丮¿¡ $secs2cache Ãʵ¿¾È ij½¬µÈ´Ù´Â °Í°ú $inputarr´Â 1Â÷¿ø ¹è¿­¸¸ Çã¿ëµÈ´Ù´Â Á¡ÀÌ ´Ù¸£´Ù. ¸¸¾à µ¿ÀÏÇÑ µ¥ÀÌŸº£À̽º, µ¿ÀÏÇÑ »ç¿ëÀÚ ID·Î ¿¬°áÇÏ°í, µ¿ÀÏÇÑ $sql, $inputarr¸¦ »ç¿ëÇؼ­ CacheExecute()À» È£ÃâÇÑ´Ù¸é ±×¸®°í ij½¬µÈ ·¹ÄÚµå¼ÂÀÌ ¸¸·áµÇÁö ¾Ê¾ÒµÈ´Ù¸é ij½¬µÈ ·¹ÄÚµå¼ÂÀÌ ¸®ÅϵȴÙ.

  include('adodb.inc.php'); 
  include('tohtml.inc.php');
  $ADODB_CACHE_DIR = '/usr/local/ADOdbcache';
  $conn = &ADONewConnection('mysql'); 
  $conn->PConnect('localhost','userid','password','database');
  $rs = $conn->CacheExecute(15, 'select * from table'); # 15 ÃÊ Ä³½¬
  rs2html($rs); /* ·¹ÄÚµå¼ÂÀ» HTML Ç¥·Î */  

ADOdb 1.80 ÀÌÈÄ·Î $secs2cache ¸Å°³º¯¼ö´Â ¿É¼ÇÀÌ´Ù:

	$conn->Connect(...);
   	$conn->cacheSecs = 3600*24; // 24 ½Ã°£ ij½¬
	$rs = $conn->CacheExecute('select * from table');
$secs2cache ¸Å°³º¯¼ö¸¦ ´©¶ôÇÑ °æ¿ì $connection->cacheSecs(±âº»°ªÀº 3600ÃÊ ¶Ç´Â 1½Ã°£)ÀÌ »ç¿ëµÈ´Ù. SELECT ¹®¸¸ CacheExecute()¸¦ »ç¿ëÇÒ ¼ö ÀÖ´Ù.

¼º´É ÁÖÀÇ: ÇÊÀÚ´Â ¸î¸î º¥Ä¡¸¶Å©¸¦ ¼öÇàÇßÀ¸¸ç ij½¬ÀÇ ¼º´É»ó ÀÕÁ¡Àº Å©°Ô º¯ÇÑ´Ù´Â °ÍÀ» ¾Ë ¼ö ÀÖ¾ú´Ù. µ¥ÀÌŸº£À̽º ¼­¹ö°¡ À¥ ¹ö¼­¿¡ºñÇØ ¾ÆÁÖ ´À¸®°Å³ª µ¥ÀÌŸº£À̽º ¼­¹ö°¡ Áö³ªÄ¡°Ô °úºÎÇÏ°¡ °É¸° °æ¿ì ADOdbÀÇ Ä³½¬´Â µ¥ÀÌŸº£À̽º ¼­¹öÀÇ ºÎÇϸ¦ ÁÙ¿©ÁÙ ¼ö Àֱ⶧¹®¿¡ ¾ÆÁÖ È¿°úÀûÀÌ´Ù. ±×·¯³ª µ¥ÀÌŸº£À̽º ¼­¹öÀÇ ºÎÇÏ°¡ ½ÉÇÏÁö ¾Ê°Å³ª À¥ ¼­¹ö¿¡ºñÇØ ÈξÀ ºü¸£´Ù¸é ij½³Àº ¿ÀÈ÷·Á ¼º´ÉÀ» °¨¼Ò½ÃŲ´Ù.

ExecuteCursor($sql,$cursorName='rs',$parameters=false)

¿À¶óŬÀÇ ÀúÀåµÈ ÇÁ·Î½ÃÁ®¸¦ ½ÇÇàÇÏ°í ¿À¶óŬÀÇ REF Ä¿¼­ º¯¼ö¸¦ Á¤±Ô ADOdb ·¹ÄÚµå¼ÂÀ¸·Î ¹ÝȯÇÑ´Ù. ÀÌ °ÍÀº oci8À» Á¦¿ÜÇÑ ¾î¶² ´Ù¸¥ µ¥ÀÌŸº£À̽º¿¡¼­µµ µ¿ÀÛÇÏÁö ¾Ê´Â´Ù. ÀÌ °ÍÀ» ¼³°èÇÑ Robert Tuttle¿¡ °¨»çÇÑ´Ù.

    $db = ADONewConnection("oci8"); 
    $db->Connect("foo.com:1521", "uid", "pwd", "FOO"); 
    $rs = $db->ExecuteCursor("begin :cursorvar := getdata(:param1); end;", 
					'cursorvar',
					array('param1'=>10)); 
    # $rs´Â ÀÌÁ¦ ADOdb ·¹ÄÚµå¼Â °³Ã¼Ã³·³ µ¿ÀÛÇÑ´Ù
    rs2html($rs);

ExecuteCursor()´Â ³»ºÎÀûÀ¸·Î ´ÙÀ½°ú °°ÀÌ µ¿ÀÛÇÏ´Â º¸Á¶ ÇÔ¼öÀÌ´Ù:

	$stmt = $db->Prepare("BEGIN :RS := SP_FOO(); END;");
	$db->Parameter($stmt, $cur, 'RS', false, -1, OCI_B_CURSOR);
	$rs = $db->Execute($stmt);

SelectLimit($sql,$numrows=-1,$offset=-1,$inputarr=false)

¼º°øÇÏ¸é ·¹ÄÚµå¼ÂÀÌ ¸®ÅϵȴÙ. ±×·¸Áö ¾ÊÀ¸¸é °ÅÁþÀÌ ¸®ÅϵȴÙ. PostgreSQLÀÇ LIMIT $numrows OFFSET $offset ±¸¸¦ Èä³»³½ SELECT ¹®À» ¼öÇàÇÑ´Ù.

PostgreSQL¿¡¼­ SELECT * FROM TABLE LIMIT 3Àº ´ÜÁö ¼¼°³ÀÇ ·¹Äڵ常 ¸®ÅÏÇÑ´Ù. ÀÌ °ÍÀº $connection->SelectLimit('SELECT * FROM TABLE',3)¿Í µ¿ÀÏÇÏ´Ù. ÀÌ ±â´ÉÀº ÀÌ·¯ÇÑ Æ¯Â¡À» Áö¿øÇÏÁö¾Ê´Â µ¥ÀÌŸº£À̽ºÀÇ °æ¿ì ½Ã¹Ä·¹ÀÌÆ®µÈ´Ù.

SELECT * FROM TABLE LIMIT 3 OFFSET 2Àº 3, 4, 5 ·¹Äڵ尡 ¸®ÅϵȴÙ(¿¹: ·¹ÄÚµå 2ÀÌÈÄÀÇ 3Çà). ÀÌ °ÍÀº ADOdb¿¡¼­ $connection->SelectLimit('SELECT * FROM TABLE',3,2)¸¦ ½ÇÇàÇÏ´Â °Í°ú µ¿ÀÏÇÏ´Ù.

ÁÖÀÇ: ÀÌ °ÍÀº MySQLÀÇ LIMIT ±¸¿Í´Â ¹Ý´ëÀÌ´Ù. ¸¶Áö¸· ÇàÀ¸·ÎºÎÅÍ 11°³ÀÇ ÇàÀ» °¡Á®¿À±âÀ§ÇØ $connection->SelectLimit('SELECT * FROM TABLE',-1,10)¸¦ ½ÇÇàÇÒ ¼ö ÀÖ´Ù.

¸¶Áö¸· ¸Å°³º¯¼ö $inputarr´Â Oracle oci8°ú°°ÀÌ º¯¼ö ¹ÙÀεùÀ» Áö¿øÇÏ´Â µ¥ÀÌŸº£À̽º¸¦ À§ÇÑ °ÍÀÌ´Ù. ÀÌ °ÍÀº °á°úÀûÀ¸·Î SQL ÄÄÆÄÀÏ ¿À¹öÇìµå¸¦ ÁÙ¿©ÁØ´Ù. ´ÙÀ½Àº OracleÀÇ ¿¹ÀÌ´Ù:

 $conn->SelectLimit("SELECT * FROM TABLE WHERE COND=:val", 100,-1,array('val'=> $val));
 

oci8po µå¶óÀ̹ö(¿À¶óŬ ȣȯ µå¶óÀ̹ö)´Â º¸´Ù Ç¥ÁØÀûÀÎ ¹ÙÀεù º¯¼ö, ?¸¦ »ç¿ëÇÑ´Ù.

 $conn->SelectLimit("SELECT * FROM TABLE WHERE COND=?", 100,-1,array('val'=> $val));

Ron WilsonÀÇ º¸°í¿¡µû¸£¸é SelectLimit´Â UNION°ú´Â µ¿ÀÛÇÏÁö ¾Ê´Â´Ù°í ÇÑ´Ù.

CacheSelectLimit([$secs2cache,] $sql, $numrows=-1,$offset=-1,$inputarr=false)

SelectLimit¿Í À¯»çÇÏÁö¸¸ ¸®ÅÏµÈ ·¹ÄÚµå¼ÂÀÌ $ADODB_CACHE_DIR µð·ºÅ丮¿¡ $secs2cache Ãʵ¿¾È ij½¬µÈ´Ù´Â °ÍÀÌ ´Ù¸£´Ù.

1.80 ÀÌ·¡ $secs2cacheÀº ¿É¼ÇÀ̸ç, $connection->cacheSecs¿¡¼­ ij½¬µÉ ½Ã°£À» Á¤ÀÇÇÒ ¼ö ÀÖ´Ù.

	$conn->Connect(...);
	$conn->cacheSecs = 3600*24; // 24½Ã°£ ij½¬
	$rs = $conn->CacheSelectLimit('select * from table',10);

CacheFlush($sql=false,$inputarr=false)

$ADODB_CACHE_DIR¿¡ SQL¹® $sql¿¡´ëÇØ Ä³½¬µÈ ÀÓÀÇÀÇ ·¹ÄÚµå¼ÂÀ» »èÁ¦ÇÑ´Ù.

¸Å°³º¯¼ö¸¦ ÁöÁ¤ÇÏÁö ¾ÊÀ¸¸é ¸ðµç adodb_*.cache ÆÄÀÏÀÌ »èÁ¦µÈ´Ù.

ij½¬µÈ ·¹ÄÚµå¼ÂÀ» ¼öÀÛ¾÷À¸·Î »èÁ¦ÇÏ±æ ¿øÇÑ´Ù¸é ´ÙÀ½ PHP ÄÚµå(À¯´Ð½º¿¡¼­¸¸ µ¿ÀÛÇÔ)¸¦ ½ÇÇàÇϱ⠹ٶõ´Ù::
  system("rm -f `find ".$ADODB_CACHE_DIR." -name adodb_*.cache`");

ÀϹÝÀûÀ¸·Î ¸ðµç ¸¸·áµÈ ÆÄÀÏÀÇ »èÁ¦´Â À¯´Ð½ºÀÇ °æ¿ì, crontab, À©µµ¿ìÁîÀÇ °æ¿ì at.exe¸¦ »ç¿ëÇÏ°í ´ÙÀ½°ú ºñ½ÁÇÑ šv ½ºÅ©¸³Æ®¸¦ »ç¿ëÇØ¾ß ÇÑ´Ù:
#------------------------------------------------------
# ÀÌ ¿¹´Â TMPPATH µð·ºÅ丮³»ÀÇ ÆÄÀÏÀ» »èÁ¦ÇÑ´Ù
# »èÁ¦µÇ´Â ÆÄÀÏÀº À̸§¿¡ ".cache"¸¦ Æ÷ÇÔÇÏ°í ÀÖÀ¸¸ç
# »ý¼ºÀÏÀÚ°¡ 7ÀÏ ÀÌ»óµÈ ÆÄÀϵéÀÌ´Ù.
#------------------------------------------------------
AGED=7
find ${TMPPATH} -mtime +$AGED | grep "\.cache" | xargs rm -f

MetaError($errno=false)

PEAR DB ¿À·ù ¹øÈ£ ½Ã½ºÅÛÀ» ±âÃÊ·Î °¡»óÈ­µÈ ¿À·ù ¹øÈ£¸¦ ¸®ÅÏÇÑ´Ù. ÀÌ ÇÔ¼ö¸¦ È£ÃâÇϱâÀü¿¡ adodb-error.inc.php¸¦ IncludeÇØ¾ß ÇÑ´Ù. ¸Å°³º¯¼ö¸¦ ÁöÁ¤ÇÏÁö ¾ÊÀ¸¸é MetaError´Â ErrorNo()¸¦ È£ÃâÇϸç, ÀÌ °ÍÀ» º¯È¯ÇÑ´Ù. ¿À·ù ¹øÈ£°¡ °¡»óÈ­µÇÁö ¾ÊÀ¸¸é MetaError´Â -1(DB_ERROR)À» ¸®ÅÏÇÑ´Ù.

MetaErrorMsg($errno)

¿À·ù ¸Þ½ÃÁö¸¦ º¹¿øÇϱâÀ§ÇØ MetaError()¿¡ÀÇÇØ ¸®ÅÏµÈ ¿À·ù ¹øÈ£¸¦ Àü´ÞÇÑ´Ù.

ErrorMsg()

¸¶Áö¸· »óųª ¿À·ù ¸Þ½ÃÁö¸¦ ¸®ÅÏÇÑ´Ù. ÀÌ °ÍÀº ¿À·ù°¡ ¹ß»ýÇÏÁö ¾ÊÀº °Ü¿ì¿¡µµ ¹®ÀÚ¿­À» ¸®ÅÏÇÒ ¼ö ÀÖ´Ù. ÀϹÝÀûÀ¸·Î ADOdb ÇÔ¼ö°¡ ¿À·ù½Ã °ÅÁþÀ» ¸®ÅÏÇÏ´Â °æ¿ì¸¦ Á¦¿ÜÇÏ°í ÀÌ ÇÔ¼ö¸¦ È£ÃâÇÒ ÇÊ¿ä´Â ¾ø´Ù.

ÁÖÀÇ: debug¸¦ ÂüÀ¸·Î ¼³Á¤ÇÑ °æ¿ì Execute ÇÔ¼ö°¡ È£ÃâµÉ ¶§ SQL ¿À·ù ¸Þ½ÃÁö´Â Ç×»ó Ãâ·ÂµÈ´Ù.

ErrorNo()

¸¶Áö¸· ¿À·ù ¹øÈ£¸¦ ¸®ÅÏÇÑ´Ù. ÀÌÀü ¹öÀüÀÇ PHP(4.0.6 ÀÌÇÏ)´Â ODBC¿¡´ëÇÑ ¿À·ù ¹øÈ£¸¦ Áö¿øÇÏÁö ¾Ê´Â´Ù´Â °Í¿¡ ÁÖÀÇÇϱ⠹ٶõ´Ù. ÀϹÝÀûÀ¸·Î ADOdb ÇÔ¼ö°¡ ¿À·ù½Ã °ÅÁþÀ» ¸®ÅÏÇÏ´Â °æ¿ì¸¦ Á¦¿ÜÇÏ°í ÀÌ ÇÔ¼ö¸¦ È£ÃâÇÒ ÇÊ¿ä´Â ¾ø´Ù.

SetFetchMode($mode)

ÇöÀçÀÇ ÆäÄ¡ ¸ðµå¸¦ ¼³Á¤ÇÏ°í ¼³Á¤µÈ °ªÀ» $db->fetchMode¿¡ ÀúÀåÇÑ´Ù. »ç¿ëÇÒ ¼ö ÀÖ´Â ¸ðµå´Â ADODB_FETCH_ASSOC°ú ADODB_FETCH_NUMÀÌ´Ù. º¸´Ù ÀÚ¼¼ÇÑ Á¤º¸´Â $ADODB_FETCH_MODE¸¦ º¸±â ¹Ù¶õ´Ù.

ÀÌÀü ÆäÄ¡ ¸ðµå¸¦ ¸®ÅÏÇÑ´Ù. SetFetchMode( )°¡ ÀÌÀü¿¡ È£ÃâµÈ ÀûÀÌ ¾ø´Ù¸é °ÅÁþÀÌ ¸®Å쵃 ¼ö ÀÖ´Ù.

CreateSequence($seqName = 'adodbseq',$startID=1)

½ÃÄö½º¸¦ »ý¼ºÇÑ´Ù. ´ÙÀ½¹ø¿¡ GenID( )°¡ È£ÃâµÇ¸é ¸®ÅÏµÈ °ªÀº $startID°¡ µÈ´Ù. ADOdb 2.60¿¡¼­ Ãß°¡µÇ¾ú´Ù.

DropSequenceD($seqName = 'adodbseq')

½ÃÄö½º¸¦ »èÁ¦ÇÑ´Ù. ADOdb 2.60¿¡¼­ Ãß°¡µÇ¾ú´Ù.

GenID($seqName = 'adodbseq',$startID=1)

½ÃÄö½º ¹øÈ£¸¦ »ý¼ºÇÑ´Ù. ÇöÀç interbase, mysql, postgresql, oci8, oci8pro, mssql, ODBC¿¡ ±Ù°ÅÇÑ µå¶óÀ̹ö(access, vfp, db2µî)¿Í µ¿ÀÛÇÑ´Ù. ½ÃÄö½ºÀÇ À̸§À¸·Î¼­ $sqlName¸¦ »ç¿ëÇÑ´Ù. GenID()´Â ½ÃÄö½º°¡ Á¸ÀçÇÏÁö¾Ê´Â °æ¿ì ÀÚµ¿ÀûÀ¸·Î ½ÃÄö½º¸¦ »ý¼ºÇÑ´Ù(Á¦°øµÈ »ç¿ëÀÚ ID°¡ ±ÇÇÑÀÌ ÀÖ´Â °æ¿ì). ±×·¸Áö¾ÊÀ¸¸é ½º½º·Î ½ÃÄö½º¸¦ »ý¼ºÇØ¾ß ÇÑ´Ù.

µ¥ÀÌŸº£À̽º µå¶óÀ̹ö°¡ ½ÃÄö½º¸¦ ¿¡¹Ä·¹À̼ÇÇÏ´Â °ÍÀ̶ó¸é Å×À̺íÀÇ À̸§ÀÌ ½ÃÄö½ºÀÇ À̸§ÀÌ µÈ´Ù. Å×À̺íÀº ÇϳªÀÇ Ä÷³, "id"¸¦ °¡Áö°í ÀÖ¾î¾ß Çϸç, Ä÷³ÀÇ Å¸ÀÔÀº Á¤¼ö ¶Ç´Â numeric(16)º¸´Ù Å« °ÍÀÌ¾ß ÇÑ´Ù.

ODBC¿Í ½ÃÄö½º¸¦ Áö¿øÇÏÁö ¾Ê´Â µ¥ÀÌŸº£À̽º(¿¹: mssql, mysql) °æ¿ì, °¢ ½ÃÄö½º¿¡´ëÇÑ Å×ÀÌÀ» »ý¼ºÇÑ´Ù. ¸¸¾à ¸ÕÀú ½ÃÄö½º°¡ Á¤ÀǵÇÁö¾Ê¾Ò´Ù¸é $startID¿¡¼­ ¼³Á¤µÈ ½ÃÀÛ°ªÀ¸·Î »ý¼ºµÈ´Ù.

ÁÖÀÇ: ADOdb 1.9 ÀÌÇÏÀÇ mssql µå¶óÀ̹öÀÇ GenID()´Â 16 ¹ÙÀÌÆ®ÀÇ GUID¸¦ »ý¼ºÇϴµ¥ »ç¿ëµÈ´Ù.

UpdateBlob($table,$column,$val,$where)

blob($val¿¡)À» $tableÀÇ $where°¡ Áö½ÃÇÏ´Â ÇàÀÇ $column¿¡ ÀúÀåÇÒ ¼ö ÀÖ´Ù.

»ç¿ë¿¹:

	# ¿À¶óŬÀÇ °æ¿ì
	$conn->Execute('INSERT INTO blobtable (id, blobcol) VALUES (1, empty_blob())');
	$conn->UpdateBlob('blobtable','blobcol',$blobvalue,'id=1');
	
	# ´Ù¸¥ DBÀÇ °æ¿ì
	$conn->Execute('INSERT INTO blobtable (id, blobcol) VALUES (1, null)');
	$conn->UpdateBlob('blobtable','blobcol',$blobvalue,'id=1');

¼º°øÇϸé ÂüÀÌ ¸®ÅϵǸç, ±×·¸Áö ¾ÊÀº °æ¿ì °ÅÁþÀÌ ¸®ÅϵȴÙ. MySQL, PostgreSQL, Oci8, Oci8pro¿Í Interbase µå¶óÀ̹ö¿¡ÀÇÇØ Áö¿øµÈ´Ù. ´Ù¸¥ µå¶óÀ̹ö´Â ÇØ´ç µå¶óÀ̹öÀÇ °³¹ß »óȲ¿¡µû¶ó µ¿ÀÛÇÒ ¼öµµ ÀÖ´Ù.

ÁÖÀÇ: Interbase blob´Â SELECT¸¦ »ç¿ëÇؼ­ º¹¿øÇÒ ¶§ ¿ø·¡ÀÇ °ªÀ» ²ø¾î³»±âÀ§ÇØ $connection->DecodeBlob($blob);¸¦ »ç¿ëÇؼ­ µðÄÚµåÇÒ ÇÊ¿ä°¡ ÀÖ´Ù(PHP 4.1.0 ÀÌÇÏ ¹öÀü).

PostgreSQLÀÇ °æ¿ì blob oid¸¦ »ç¿ëÇϰųª bytea Çʵå·Î ÀúÀåÇÒ ¼ö ÀÖ´Ù. UpdateBlob( )Àº bytea Çʵå´Â »ç¿ëÇÒ ¼ö ÀÖÁö¸¸ oid´Â »ç¿ëÇÒ ¼ö ¾ø´Ù. ¹Ý´ë·Î UpdateBlobFile( )´Â oid¸¦ Áö¿øÇÏÁö¸¸ bytea µ¥ÀÌŸ´Â Áö¿øÇÏÁö ¾Ê´Â´Ù

¸¸¾à oid·Î Àü´ÞµÇÁö¾ÊÀ¸¸é UpdateBlob()´Â bytea Çʵ忡 ÀúÀåµÈ °ÍÀ¸·Î °£ÁÖÇÑ´Ù.

UpdateClob($table,$column,$val,$where)

clob($valÀÇ)À» $tableÀÇ $where°¡ Áö½ÃÇÏ´Â ÇàÀÇ $column¿¡ ÀúÀåÇÒ ¼ö ÀÖ´Ù. UpdateBlob¿Í À¯»çÇÏÁö¸¸ Character Large OBjects¶ó´Â Á¡ÀÌ ´Ù¸£´Ù.

»ç¿ë¿¹:

	# ¿À¶óŬ
	$conn->Execute('INSERT INTO clobtable (id, clobcol) VALUES (1, empty_clob())');
	$conn->UpdateBlob('clobtable','clobcol',$clobvalue,'id=1');
	
	# ´Ù¸¥ DBÀÇ °æ¿ì
	$conn->Execute('INSERT INTO clobtable (id, clobcol) VALUES (1, null)');
	$conn->UpdateBlob('clobtable','clobcol',$clobvalue,'id=1');

UpdateBlobFile($table,$column,$path,$where,$blobtype='BLOB')

UpdateBlob°ú ºñ½ÁÇÏÁö¸¸ blob°¡ À§Ä¡ÇÑ ÆÄÀÏ °æ·Î¸¦ Àü´ÞÇÏ´Â °ÍÀÌ ´Ù¸£´Ù.

PostgreSQLÀÇ °æ¿ì blob oid¸¦ »ç¿ëÇÏ´Â °æ¿ì ÀÌ ÀÎÅÍÆäÀ̽º¸¦ »ç¿ëÇÑ´Ù. ÀÌ ÀÎÅÍÆäÀ̽º´Â bytea Çʵ带 Áö¿øÇÏÁö ¾Ê´Â´Ù.

¼º°íÇϸé ÂüÀ», ±×·¸Áö ¾ÊÀ¸¸é °ÅÁþÀ» ¸®ÅÏÇÑ´Ù.

BlobEncode($blob)

¸î¸î µ¥ÀÌŸº£½Ã½º´Â ¾÷·ÎµåÀü¿¡ ¼öÀÛ¾÷À¸·Î blob¸¦ ÀÎÄÚµåÇÒ ÇÊ¿ä°¡ ÀÖ´Ù. ÁÖÀÇ: UpdateBlob( )³ª UpdateBlobFile( )¸¦ »ç¿ëÇÑ´Ù¸é º¯È¯Àº ÀÚµ¿ÀûÀ¸·Î ¼öÇàµÇ¹Ç·Î ÀÌ ÇÔ¼ö¸¦ È£ÃâÇÒ ÇÊ¿ä´Â ¾ø´Ù. PostgreSQLÀÇ °æ¿ì ÇöÀç BlobEncode()´Â bytea Çʵ忡´ëÇؼ­¸¸ »ç¿ëÇÒ ¼ö ÀÖ´Ù.

ÀÎÄÚµåµÈ blob °ªÀ» ¸®ÅÏÇÑ´Ù..

ÁÖÀÇ: blobEncodeType¶ó°í ºÎ¸£´Â Á¢¼Ó ¼Ó¼ºÀÌ Á¸ÀçÇÑ´Ù. ¼Ó¼º °ªÀº ´ÙÀ½°ú °°´Ù:

°ÅÁþ - ÀÎÄÚµå, µðÄڵ带 ¼öÇàÇÒ ÇÊ¿ä°¡ ¾øÀ½.
'I' - blob ÀÎÄÚµùÀÌ ÇÊ¿äÇÔ, ¸®ÅÏµÈ blob(ÀÎÄÚµåµÈ)Àº ¼ýÀÚ·Î ±¸¼ºµÈ(ÀοëÇÒ ÇÊ¿ä´Â ¾øÀ½).
'C' - blob ÀÎÄÚµùÀÌ ÇÊ¿äÇÔ, ¸®ÅÏµÈ blob(ÀÎÄÚµåµÈ)Àº ¹®ÀÚ·Î ±¸¼ºµÊ(ÀοäÇÒ ÇÊ¿ä°¡ ÀÖÀ½).

ÀÌ °ÍÀº ¼øÀüÈ÷ ¹®¼­È­ ¸ñÀûÀ¸·Î¸¸ »ç¿ëµÈ´Ù. ´ÙÁß µ¥ÀÌŸº£À̽º µå¶óÀ̹ö¸¦ Çã¿ëÇÏ´Â ÇÁ·Î±×·¥Àº blob¸¦ ó¸®ÇÒ ¶§ ÇؾßÇÏ´Â ¿Ã¹Ù´Â °ÍÀÌ ¹«¾úÀÎÁö ¾Ë°í ÀÖ´Ù.

BlobDecode($blob)

¸î¸î µ¥ÀÌŸº£À̽º´Â SELECT ¹®À» ¼öÇàÇÑ ÈÄ ¼öÀÛ¾÷À¸·Î blob¸¦ µðÄÚµåÇؾßÇÑ´Ù. ¸¸¾à µ¥ÀÌŸº£À̽º°¡ µðÄÚµùÀ» ÇÊ¿ä·ÎÇÏÁö ¾Ê´Â´Ù¸é ÀÌ ÇÔ¼ö´Â º¯°æµÇÁö¾Ê´Â blob¸¦ ¸®ÅÏÇÑ´Ù. ÇöÀç BlobDecode´Â ´Ü ÇϳªÀÇ µ¥ÀÌŸº£À̽º, PostgreSQL¿¡¼­, blob oid¸¦ »ç¿ëÇÏ´Â °æ¿ì¿¡¸¸ ÇÊ¿äÇÏ´Ù(¸¸¾à bytea Çʵ带 »ç¿ëÇÑ´Ù¸é ÀÚµ¿ÀûÀ¸·Î µðÄÚµåµÈ´Ù).

$rs = $db->Execute("select bloboid from postgres_table where id=$key");
$blob = $db->BlobDecode( reset($rs->fields) );

Replace($table, $arrFields, $keyCols,$autoQuote=false)

·¹Äڵ带 °»½ÅÇÑ´Ù. ¸¸¾à ·¹Äڵ尡 Á¸ÀçÇÏÁö¾Ê´Â´Ù¸é »ðÀԵȴÙ. ½ÇÆнà 0ÀÌ ¸®ÅϵǸç, °»½Å½Ã 1ÀÌ, »ðÀԽà 2°¡ ¸®ÅϵȴÙ. ÀÌ ÇÔ¼ö´Â MySQLÀÇ Replace¿Í ´Ù¸£´Ù. MySQLÀÇ Replace´Â ·¹Äڵ带 »èÁ¦ÇÑ ÈÄ, »õ·Î¿î ·¹Äڵ带 »ðÀÔÇÑ´Ù. ÀÌ °ÍÀº ¶ÇÇÑ ÇÁ¶óÀ̸Ӹ® Å°´Â ¾÷µ¥ÀÌÆ® ÇÒ ¼ö ¾øÀ½À» ÀǹÌÇÑ´Ù. ÀÌ °ÍÀÇ À¯ÀÏÇÑ ¿¹¿Ü´Â Interbase¿Í Interbase·ÎºÎÅÍ À¯µµµÈ µå¶óÀ̹öÀÌ´Ù. InterbaseÀÇ °æ¿ì Interbase API Á¦ÇÑ ¶§¹®¿¡ »èÁ¦/»ðÀÔÀ» »ç¿ëÇÑ´Ù.

¸Å°³º¯¼ö $tableÀº Å×ÀÌºí ¸íÀ̸ç, $arrFields´Â Çʵå¸íÀ» Å°·ÎÇÏ´Â ¿¬°ü¹è¿­À̸ç, $KeyCols´Â ÇÁ¶óÀ̸Ӹ® Å°À̰ųª ÇÁ¶óÀ̸Ӹ® Å°ÀÇ ¹è¿­(Á¶ÇÕ Å°ÀÎ °æ¿ì)À̾î¾ß ÇÑ´Ù. $autoQuote°¡ ÂüÀ¸·Î ¼³Á¤µÇ¸ç, Replace()´Â Numeric ÇüÀ» Á¦¿ÜÇÑ ¸ðµç ÇüÀ» ÀοëÇÑ´Ù. ÀÚµ¿ ÀοëÀº NullÀº ÀοëÇÏÁö´Â ¾Ê´Â´Ù. ÀÚµ¿ ÀοëÀº SQL ÇÔ¼ö³ª ¿¬»êÀÚ¸¦ »ç¿ëÇÏ¸é µ¿ÀÛÇÏÁö ¾Ê´Â´Ù.

¿¹:

# ÇϳªÀÇ ÇÁ¶óÀ̸Ӹ® Å°
$ret = $db->Replace('atable', 
	array('id'=>1000,'firstname'=>'Harun','lastname'=>'Al-Rashid'),
	'id',$autoquote = true);	
# UPDATE atable SET firstname='Harun',lastname='Al-Rashid' WHERE id=1000 À̳ª
# INSERT INTO atable (id,firstname,lastname) VALUES (1000,'Harun','Al-Rashid') »ý¼º

# Á¶ÇÕÅ°
$ret = $db->Replace('atable2', 
	array('firstname'=>'Harun','lastname'=>'Al-Rashid', 'age' => 33, 'birthday' => 'null'),
	array('lastname','firstname'),
	$autoquote = true);

# ÀÚµ¿ ÀÎ¿ë »ç¿ë ¾ÈÇÔ
$ret = $db->Replace('atable2', 
	array('firstname'=>"'Harun'",'lastname'=>"'Al-Rashid'", 'age' => 'null'),
	array('lastname','firstname'));	

GetUpdateSQL(&$rs, $arrFields, $forceUpdate=false,$magicq=false)

·¹ÄÚµå¼Â $rs·Î ÁÖ¾îÁø Å×À̺íÀ» °»½ÅÇÒ ¼ö ÀÖ´Â SQL ¹®À» »ý¼ºÇÑ´Ù. º¯°æµÈ ¹è¿­ Çʵå $arrFields°¡ ÇöÀç ·¹ÄÚµå¼Â°ú ºñ±³µÈ´Ù. $arrFields´Â Ä÷³¸íÀ» Å°, »õ·Î¿î°ªÀ» °ªÀ¸·ÎÇÏ´Â ¿¬°ü¹è¿­ÀÌ´Ù. ¸¸¾à $forceUpdate°¡ ÂüÀ̸é $arrFields°¡ $rs->fields¿Í µ¿ÀÏÇÒ Áö¶óµµ SQL ¹®À» »ý¼ºÇÑ´Ù. °ü·Ã ·¹ÄÚµå¼ÂÀÌ ÇÊ¿äÇÏ´Ù. $magicq´Â ¸ÅÁ÷ Quote(qstr()À» ÂüÁ¶)¸¦ »ç¿ëÇÒ °ÍÀÎÁö ¾Æ´ÑÁö¸¦ Áö½ÃÇϴµ¥ »ç¿ëµÈ´Ù. ¹è¿­ÀÇ Çʵå¸íÀº ´ë¼Ò¹®ÀÚ¸¦ ±¸ºÐÇÏÁö ¾Ê´Â´Ù.

3.61 ÀÌ·¡·Î define('ADODB_FORCE_NULLS',1)°ú ¸ðµç PHP ³ÎÀº SQL ³Î·Î ÀÚµ¿ º¯È¯µÈ´Ù.

GetInsertSQL(&$rs, $arrFields,$magicq=false)

·¹ÄÚµå¼Â $rs·Î ÁÖ¾îÁø Å×ÀÌºí¿¡ »ðÀÔÇÒ ¼ö ÀÖ´Â SQL ¹®À» »ý¼ºÇÑ´Ù. °ü·Ã ÁúÀǸ¦ ÇÊ¿ä·ÎÇÑ´Ù. $magicq´Â Quote(qstr()À» ÂüÁ¶)¸¦ »ç¿ëÇÒ °ÍÀÎÁö ¾Æ´ÑÁö¸¦ Áö½ÃÇϴµ¥ »ç¿ëµÈ´Ù. ¹è¿­ÀÇ Çʵå¸íÀº ´ë¼Ò¹®ÀÚ¸¦ ±¸ºÐÇÏÁö ¾Ê´Â´Ù.

3.61 ÀÌ·¡·Î define('ADODB_FORCE_NULLS',1)°ú ¸ðµç PHP ³ÎÀº SQL ³Î·Î ÀÚµ¿ º¯È¯µÈ´Ù.

PageExecute($sql, $nrows, $page, $inputarr=false)

·¹ÄÚµå¼ÂÀ» ÆäÀÌÁöÈ­Çϴµ¥ »ç¿ëµÈ´Ù. $page´Â 1 ºÎÅÍ ½ÃÀ۵ȴÙ. ÂüÁ¶: ¿¹ 8.

CachePageExecute($secs2cache, $sql, $nrows, $page, $inputarr=false)

·¹ÄÚµå¼ÂÀ» ÆäÀÌÁöÈ­Çϴµ¥ »ç¿ëµÈ´Ù. $page´Â 1ºÎÅÍ ½ÃÀ۵ȴÙ. ÂüÁ¶: ¿¹ 8. PageExecuteÀÇ Ä³½¬¹öÀüÀÌ´Ù.

Close( )

µ¥ÀÌŸº£À̽º Á¢¼ÓÀ» ´Ý´Â´Ù. PHP¿¡¼­´Â PHP4ÀÇ ÂüÁ¶ °è¼ö ¸ÞÄ«´ÏÁòÀÌ ÀÚµ¿ÀûÀ¸·Î Á¢¼ÓÀ» »èÁ¦Çϱ⶧¹®¿¡ Á¢¼Ó Á¾·á½Ã ´õÀÌ»ó °­Á¦·Î Á¢¼ÓÀ» ÇØÁ¦ÇÒ ÇÊ¿ä°¡ ¾ø´Ù°í ¾ð±ÞÇÏ°í ÀÖ´Ù.

StartTrans( )

Æ®·£Àè¼Ç °¨½Ã¸¦ ½ÃÀÛÇÑ´Ù. SQL ¹®ÀÌ ½ÇÇàµÊ¿¡µû¶ó ADOdb´Â SQL ¿À·ù¸¦ °¨½ÃÇÏ°í, ÀÓÀÇÀÇ ¿À·ù°¡ °ËÃâ(CompleteTrans()°¡ È£Ãâ)µÇ¸é ÀÚµ¿ ·Ñ¹éÀ» ½ÇÇàÇÑ´Ù.

¿Ö StartTrans()°¡ BeginTrans()º¸´Ù ¿ì¼öÇÑÁö ÀÌÇØÇϱâÀ§ÇØ BeginTrans()¸¦ »ç¿ëÇÑ ¸î¸î ¹æ¹ýÀ» Á¶»çÇß´Ù. ´ÙÀ½Àº Æ®·£Àè¼ÇÀ» »ç¿ëÇÏ´Â À߸øµÈ ¹æ¹ýÀÌ´Ù(¿À·ù °Ë»ç¸¦ ¼öÇàÇÏÁö ¾Ê¾ÒÀ¸¹Ç·Î):

$DB->BeginTrans();
$DB->Execute("update table1 set val=$val1 where id=$id");
$DB->Execute("update table2 set val=$val2 where id=$id");
$DB->CommitTrans();

ÀÌ ¿¹´Â table1À» °»½Å ÇÒ ¼ö ÀÖ°í, ½ÇÆнà table2¸¦ °»½Å ÇÒ ¼ö ÀÖ´Ù. ´ÙÀ½Àº º¸´Ù ³ªÀº ¹æ¹ýÀÌ´Ù:

$DB->BeginTrans();
$ok = $DB->Execute("update table1 set val=$val1 where id=$id");
if ($ok) $ok = $DB->Execute("update table2 set val=$val2 where id=$id");
if ($ok) $DB->CommitTrans();
else $DB->RollbackTrans();

´ÙÀ½Àº ¶Ç ´Ù¸¥ ¹æ¹ýÀÌ´Ù(ADOdb 2.0 ÀÌ»ó):

$DB->BeginTrans();
$ok = $DB->Execute("update table1 set val=$val1 where id=$id");
if ($ok) $ok = $DB->Execute("update table2 set val=$val2 where id=$id");
$DB->CommitTrans($ok);

À§ÀÇ ¿¹¿¡¼­ ¾Ë ¼ö ÀÖµíÀÌ SQL ¹®À» ¼öÇàÇÒ ¶§¸¶´Ù $ok¸¦ °¨½ÃÇØ¾ß ÇÑ´Ù. StartTrans()´Â ¸ðµç SQL ¿À·ù¸¦ °¨½ÃÇÒ ¼ö Àֱ⶧¹®¿¡ BeginTrans()¿¡ºñÇØ °³¼±µÇ¾ú´Ù. ÀÌ °ÍÀº SQL ÁúÀÇ°¡ ¼öÇàµÇ´Â ºí·¢¹Ú½º ÇÔ¼ö¸¦ È£ÃâÇÒ ¶§¿¡´Â ƯÈ÷ À¯¿ëÇÏ´Ù. ¶ÇÇÑ StartTrans ºí·°³»ÀÇ ¸ðµç BeginTrans, CommitTrans ¿Í RollbackTrans È£ÃâÀº ¹«½ÃµÈ´Ù. ½ÉÁö¿© ºí·¢¹Ú½º ÇÔ¼ö°¡ Ä¿¹ÔÀ» ¼öÇàÇÒ Áö¶óµµ ¹«½ÃµÈ´Ù.

$DB->StartTrans();
CallBlackBox();
$DB->Execute("update table1 set val=$val1 where id=$id");
$DB->Execute("update table2 set val=$val2 where id=$id");
$DB->CompleteTrans($ok);

StartTrans ºí·°Àº ÁßøµÉ ¼ö ÀÖÁö¸¸ ¾ÈÂÊÀÇ ºí·°Àº ¹«½ÃµÈ´Ù´Â °Í¿¡ ÁÖÀÇÇϱâ¹Ù¶õ´Ù.

CompleteTrans($autoComplete=true)

StartTrans()·Î È£ÃâµÈ ¸ðµç Æ®·£Àè¼ÇÀ» ¿Ï·áÇÑ´Ù. ÀÌ ÇÔ¼ö´Â SQL ¿À·ù¸¦ °¨½ÃÇÏ°í, ¿À·ù°¡ ¾øÀ¸¸é Ä¿¹ÔÇÏ°í, ±×·¸Áö ¾ÊÀ¸¸é ·Ñ¹éÇÑ´Ù. Ä¿¹Ô½Ã ÂüÀÌ ¸®ÅϵǸç, ·Ñ¹é½Ã °ÅÁþÀÌ ¸®ÅϵȴÙ. ¸Å°³º¯¼ö $autoCompleteÀÌ ÂüÀ̸é SQL ¿À·ù¸¦ °¨½ÃÇÏ°í °á°ú¿¡µû¶ó Àû´çÈ÷ Ä¿¹Ô, ·Ñ¹éÇÑ´Ù. SQL ¿À·ù°¡ °ËÃâµÇÁö¾ÊÀº °æ¿ì¿¡µµ ·Ñ¹éÇÏ·Á¸é $autoComplete¸¦ °ÅÁþÀ¸·Î ¼³Á¤ÇÑ´Ù.

FailTrans( )

StartTrans()·Î ½ÃÀÛµÈ Æ®·£Àè¼ÇÀ» ½ÇÆÐÇÏ°Ô ÇÑ´Ù. CompleteTrans()ÀÌ È£ÃâµÇ¸é ÀÏ´Ü ·Ñ¹éÀÌ ¼öÇàµÈ´Ù.

HasFailedTrans( )

Áö´ÉÀû Æ®·£Àè¼ÇÀÇ ½ÇÆÐ ¿©ºÎ¸¦ °Ë»çÇÑ´Ù. ¿¹: SQL ¼öÇà»óÀÇ ¿À·ù°¡ ¹ß»ýÇ߰ųª FailTrans()°¡ È£ÃâµÈ °æ¿ì ÂüÀÌ ¸®ÅϵȴÙ. SmartTrans() ºí·° ³»°¡ ¾Æ´Ï¶ó¸é °ÅÁþÀÌ ¸®ÅϵȴÙ.

BeginTrans( )

Æ®·£Àè¼ÇÀ» ½ÃÀÛÇÑ´Ù. ÀÚµ¿ Ä¿¹ÔÀº »ç¿ëµÇÁö¾Ê´Â´Ù. ¼º°øÀûÀÎ °æ¿ì ÂüÀÌ ¸®ÅϵȴÙ. Æ®·£Àè¼ÇÀ» Áö¿øÇÏÁö ¸øÇÏ´Â ¸î¸î µ¥ÀÌŸº£À̽º´Â Ç×»ó °ÅÁþÀ» ¸®ÅÏÇÑ´Ù. ÀÓÀÇÀÇ ¿­·ÁÁø Æ®·£Àè¼ÇÀº Á¢¼ÓÀÌ Á¾·áµÉ ¶§ ·Ñ¹éµÈ´Ù. Æ®·£Àè¼ÇÀ» Áö¿øÇÏ´Â µ¥ÀÌŸº£À̽º Áß¿¡´Â Oracle, PostgreSQL, Interbase, MSSQL, ¸î¸î MySQL ¹öÀü, DB2, Informix, SybaseµîÀÌ ÀÖ´Ù.

StartTrans()¿Í CompleteTrans()°¡ Æ®·£Àè¼ÇÀ» ó¸®ÇÏ´Â º¸´Ù ³ªÀº ¹æ¹ýÀ̸ç, ÀÌ ±â´ÉÀº ADOdb 3.40 ÀÌ»ó ¹öÀü¿¡¼­ »ç¿ëÇÒ ¼ö ÀÖ´Ù. º¸´Ù ÀÚ¼¼ÇÑ ¼³¸íÀº StartTrans() ¹®¼­¸¦ º¸±â ¹Ù¶õ´Ù.

¿À·ù½Ã ½ºÅ©¸³Æ®¸¦ Á¾·áÇÏ°í ¸í½ÃÀûÀ¸·Î Æ®·£Àè¼ÇÀ» ·Ñ¹éÇϱâÀ§ÇØ ADOdb ¿À·ù 󸮱⸦ »ç¿ëÇÒ ¼ö ÀÖ´Ù. ¸î¸î ¹ö±×°¡ ÀÖ´Â µ¥ÀÌŸº£À̽º È®Àå ¸ðµâÀº ¸ðµç Æ®·£Àè¼ÇÀ» Ä¿¹ÔÇÏ´Â °ÍÀ¸·Î ¾Ë·ÁÁ®ÀÖÀ¸¹Ç·Î ¾ÈÀüÀ» À§ÇØ ¿À·ù 󸮱⿡¼­ ¸í½ÃÀûÀ¸·Î $DB->RollbackTrans()Çϱ⸦ ¿øÇÒ ¼ö ÀÖ´Ù.

Æ®·£Àè¼Ç °ËÃâ

ADOdb 2.50 ÀÌ·¡·Î Æ®·£Àè¼ÇÀ» °ËÃâÇÒ ¼ö ÀÖ´Ù. $connection->transCnt°¡ 0 º¸´Ù Å«Áö °Ë»çÇÑ´Ù. ÀÌ º¯¼ö´Â BeginTrans()°¡ È£ÃâµÉ¶§¸¶´Ù Áõ°¡Çϸç, RollbackTrans() ¶Ç´Â CommitTrans()°¡ È£ÃâµÉ ¶§¸¶´Ù °¨¼ÒÇÑ´Ù.

CommitTrans($ok=true)

Æ®·£Àè¼ÇÀ» ¼º°øÀûÀ¸·Î Á¾·áÇÑ´Ù. ¼º°øÇϸé ÂüÀÌ ¸®ÅϵȴÙ. µ¥ÀÌŸº£À̽º°¡ Æ®·£Àè¼ÇÀ» Áö¿øÇÏÁö ¾Ê´Â °æ¿ìµµ µ¥ÀÌŸ´Â Ç×»ó Ä¿¹ÔµÊ¹Ç·Î ÂüÀÌ ¸®Å쵃 °ÍÀÌ´Ù.

¸Å°³º¯¼ö $ok=false¸¦ Àü´ÞÇÏ¸é µ¥ÀÌŸ´Â ·Ñ¹éµÈ´Ù. BeginTrans()ÀÇ ¿¹¸¦ º¸±â¹Ù¶õ´Ù.

RollbackTrans( )

Æ®·£Àè¼ÇÀ» Á¾·áÇÏ°í ¸ðµç º¯°æÀ» ·Ñ¹éÇÑ´Ù. ¼º°øÇϸé ÂüÀÌ ¸®ÅϵȴÙ. Æ®·£Àè¼ÇÀ» Áö¿øÇÏÁö¾Ê´Â µ¥ÀÌŸº£À̽ºÀÇ °æ¿ì ¾î¶°ÇÑ µ¥ÀÌŸ·Î ·Ñ¹éÇÒ ¼ö ¾øÀ¸¹Ç·Î °ÅÁþÀÌ ¸®Å쵃 °ÍÀÌ´Ù.

GetAssoc($sql,$inputarr=false,$force_array=false,$first2cols=false)

ÁÖ¾îÁø ÁúÀÇ $sql¿¡´ëÇÑ ¿¬°ü ¹è¿­À» ¸®ÅÏÇÑ´Ù. $inputarr·Î Ç¥½ÃµÇ´Â ¹ÙÀεù ¸Å°³º¯¼ö´Â ¿É¼ÇÀÌ´Ù. ¸¸¾à ¸®ÅÏµÈ Ä÷³ÀÇ ¼ö°¡ 2º¸´Ù Å©´Ù¸é 2Â÷¿ø ¹è¿­ÀÌ ¸®ÅϵȴÙ. ·¹ÄÚµå¼ÂÀÇ Ã¹¹ø° Ä÷³ÀÌ ³ª¸ÓÁö Çà¿¡´ëÇÑ Å°°¡ µÈ´Ù. Ä÷³ÀÌ 2À̸é 1Â÷¿ø ¹è¿­ÀÌ »ý¼ºµÇ¸ç, Å°´Â °ªÀ¸·Î Á÷Á¢ ¸ÅÇεȴÙ(°¢°¢ÀÇ °ª¿¡´ëÇØ ¹è¿­ÀÌ »ý¼ºµÉ¶§ $force_array°¡ ÂüÀ¸·Î ¼³Á¤µÇÁö¾ÊÀº´Ù¸é).

¿¹:

·¹ÄÚµå¼Â¿¡ ´ÙÀ½°ú °°Àº µ¥ÀÌŸ¸¦ °¡Áö°í ÀÖ´Ù°í ÇÏÀÚ:

row1: Apple, Fruit, Edible
row2: Cactus, Plant, Inedible
row3: Rose, Flower, Edible

GetAssoc´Â ´ÙÀ½°ú °°Àº 2Â÷¿ø ¿¬°ü¹è¿­À» »ý¼ºÇϰԵȴÙ:

Apple => array[Fruit, Edible]
Cactus => array[Plant, Inedible]
Rose => array[Flower,Edible]

¸¸¾à µ¥ÀÌŸ ÁýÇÏÀÌ ´ÙÀ½°ú °°´Ù¸é:

row1: Apple, Fruit
row2: Cactus, Plant
row3: Rose, Flower

GetAssocÀº ´ÙÀ½°ú °°Àº 1Â÷¿ø ¿¬°ü¹è¿­À» »ý¼ºÇϰԵȴÙ.($force_array==false Àΰæ¿ì):

Apple => Fruit
Cactus=>Plant
Rose=>Flower

ÇÔ¼ö ¸®ÅÏ:

¿¬°ü¹è¿­ ¶Ç´Â ¿À·ù°¡ ¹ß»ýÇÑ °æ¿ì °ÅÁþ.

CacheGetAssoc([$secs2cache,] $sql,$inputarr=false,$force_array=false,$first2cols=false)

À§ÀÇ GetAssoc ÇÔ¼öÀÇ Ä³½¬ ¹öÀüÀÌ´Ù.

GetOne($sql,$inputarr=false)

SQL ¹®À» ½ÇÇàÇÏ°í ùÇàÀÇ Ã¹¹ø° Çʵ带 ¸®ÅÏÇÑ´Ù. ·¹ÄÚµå¼Â°ú ³²Àº ÇàÀº ÀÚµ¿ÀûÀ¸·Î »èÁ¦µÈ´Ù. ¿À·ù°¡ ¹ß»ýÇÏ¸é °ÅÁþÀÌ ¸®ÅϵȴÙ.

GetRow($sql,$inputarr=false)

SQLÀ» ½ÇÇàÇÏ°í ù¹ø° ÇàÀ» ¹è¿­·Î ¸®ÅÏÇÑ´Ù. ·¹ÄÚµå¼Â°ú ³²Àº ÇàÀº ÀÚµ¿ÀûÀ¸·Î »èÁ¦µÈ´Ù. ¿À·ù°¡ ¹ß»ýÇÑ °æ¿ì °ÅÁþÀÌ ¸®ÅϵȴÙ.

GetAll($sql)

SQLÀ» ½ÇÇàÇÏ°í ¸ðµç ÇàÀ» 2Â÷¿ø ¹è¿­·Î ¸®ÅÏÇÑ´Ù. ·¹ÄÚµå¼ÂÀº ÀÚµ¿ÀûÀ¸·Î »èÁ¦µÈ´Ù. ¿À·ù°¡ ¹ß»ýÇÏ¸é °ÅÁþÀÌ ¸®ÅϵȴÙ.

GetCol($sql,$inputarr=false,$trim=false)

SQL ¹®À» ½ÇÇàÇÏ°í ù¹ø° Ä÷³ÀÇ ¸ðµç Ç׸ñÀ» 1Â÷¿ø ¹è¿­·Î ¸®ÅÏÇÑ´Ù. ·¹ÄÚµå¼ÂÀº ÀÚµ¿ÀûÀ¸·Î »èÁ¦µÈ´Ù. ¿À·ù°¡ ¹ß»ýÇÏ¸é °ÅÁþÀÌ ¸®ÅϵȴÙ.

CacheGetOne([$secs2cache,] $sql,$inputarr=false), CacheGetRow([$secs2cache,] $sql,$inputarr=false), CacheGetAll([$secs2cache,] $sql,$inputarr=false), CacheGetCol([$secs2cache,] $sql,$inputarr=false,$trim=false)

À§ÀÇ Get* ÇÔ¼ö¿Í ºñ½ÁÇÏÁö¸¸ ·¹ÄÚµå¼ÂÀº $ADODB_CACHE_DIR µð·ºÅ丮¿¡ $secs2cache Ãʵ¿¾È ij½¬µÇ°í ½Ã¸®¾óÈ­µÈ´Ù´Â Â÷ÀÌ°¡ÀÖ´Ù. µå¹°°Ô º¯°æµÇ´Â µ¥ÀÌŸ¿¡´ëÇÑ ÁúÀÇ ¼Óµµ¸¦ ³ôÀÌÀ̱⿡ ÁÁ´Ù. $secs2cache ¸Å°³º¯¼ö´Â ¿É¼ÇÀ̶ó´Â °Í¿¡ ÁÖÀÇÇϱ⠹ٶõ´Ù. $secs2cache¸¦ ´©¶ôÇϸé $connection->cacheSecs(±âº»°ªÀº 3600ÃÊ ¶Ç´Â Çѽð£)ÀÇ °ªÀÌ »ç¿ëµÈ´Ù.

Prepare($sql )

¹Ýº¹ÀûÀÎ ½ÇÇàÀ» À§ÇØ SQL ÁúÀǸ¦ Áغñ(ÄÄÆÄÀÏ)ÇÑ´Ù. ¹ÙÀÎµå ¸Å°³º¯¼ö´Â ?·Î Ç¥±âµÈ´Ù. oci8 µå¶óÀ̹öÀÇ °æ¿ì ÀüÅëÀûÀÎ Oracle ¹ÙÀÎµå º¯¼öÀÎ :varname·Î Ç¥±âµÈ´Ù.

¹è¿­ÀÇ Ã¹¹ø° ¿ä¼Ò¿¡ ¿ø SQL ¹®ÀÌ Æ÷ÇÔµÈ ¹è¿­À» ¸®ÅÏÇÑ´Ù. ¹è¿­ÀÇ ³ª¸ÓÁö ºÎºÐÀº µå¶óÀ̹ö¿¡µû¶ó ´Ù¸£´Ù. ¿À·ù°¡ ¹ß»ýÇϰųª Prepace( )¸¦ ¿¡¹Ä·¹À̼ÇÇÏ´Â °æ¿ì ¿ø·¡ÀÇ $sql ¹®ÀÚ¿­ÀÌ ¸®ÅϵȴÙ. ÀÌ°ÍÀº ¸ðµç ¿À·ù 󸮴 Execute( )¿¡ ÁýÁߵDZ⶧¹®ÀÌ´Ù.

Prepare( )´Â SQL Äõ¸®¸¦ ´Ù½Ã »ý¼ºÇÏ´Â ÇÔ¼ö(¿¹: PageExecute( )¿Í SelectLimit( ))¿Í´Â ÇÔ²² »ç¿ëÇÒ ¼ö ¾ø´Ù.

¿¹:

$stmt = $DB->Prepare('insert into table (col1,col2) values (?,?)');
for ($i=0; $i < $max; $i++)
$DB->Execute($stmt,array((string) rand(), $i));

¶ÇÇÑ ¾Æ·¡ÀÇ PrepareSP()¿Í Parameter()¸¦ º¸±â ¹Ù¶õ´Ù. ÀÌ °ÍÀº ³»ºÎÀûÀ¸·Î interbase, oci8°ú ¸î¸î ODBC-±â¹Ý µå¶óÀ̹ö¸¸ Áö¿øÇÑ´Ù. ±×¿ÜÀÇ °ÍµéÀº ¿¡¹Ä·¹À̼ǵȴÙ. ¿¡¹Ä·¹À̼ǵǴ °æ¿ì Prepare()¸¦ »ç¿ëÇÏ´Â °æ¿ì ¼º´É»ó ÀÕÁ¡Àº ¾ø´Ù.

Áß¿ä: PHPÀÇ Á¦ÇÑÀ̳ª ¹ö±×¶§¹®¿¡ ¹Ì¸® ÁغñµÈ ÁúÀǸ¦ »ç¿ëÇÒ ¶§ ¿À·ù¸¦ È®ÀÎÇÒ ¼ö ¾ø´Ù¸é Prepare()¸¦ »ç¿ëÇϱâ Àü¿¡ $ADODB_COUNTRECS = false·Î ¼³Á¤ÇÏ°í ½ÃµµÇϱ⠹ٶõ´Ù. ÀÌ·¯ÇÑ ¹®Á¦´Â ODBC¿¡¼­ °üÃøµÇ¾ú´Ù.

IfNull($field, $nullReplacementValue)

´Ù¸¥ DB¿Í ȣȯµÇ´Â IFNULL ÇÔ¼ö(¿À¶óŬÀÇ NVL). ÁÖ¾îÁø µ¥ÀÌŸº£À̽º¿¡´ëÇØ $field°¡ ³ÎÀÎÁö¸¦ °Ë»çÇÏ´Â ÇÔ¼ö(¹®ÀÚ¿­)¸¦ ¸®ÅÏÇÑ´Ù. ¸¸¾à ³ÎÀ̸é $nullReplacementValue·Î ¸®ÅÏµÈ °ªÀ» º¯°æÇÑ´Ù. ¿¹.

$sql = 'SELECT '.$db->IfNull('name', "'- unknown -'"). ' FROM table';

substr

ÀÌ °ÍÀº ÇÔ¼ö°¡ ¾Æ´Ï¶ó ¼Ó¼ºÀÌ´Ù. ¸î¸î µ¥ÀÌŸº£À̽º´Â ºÎºÐ ¹®ÀÚ¿­À» º¹»çÇÏ´Â ÇÔ¼ö·Î "substr"°ú "substring"¸¦ °¡Áö°í ÀÖ´Ù. ÀÌ ¼Ó¼ºÀº ´ÙÀ½°ú °°ÀÌ »ç¿ëÇÑ´Ù:

  $sql = "SELECT ".$db->substr."(field, $offset, $length) from table";
  $rs = $db->Execute($sql);

¸ðµç µ¥ÀÌŸº£À̽º¿¡¼­ substrÀÇ Ã¹¹ø° ¸Å°³º¯¼ö´Â ÇʵåÀ̸ç, µÎ¹ø°´Â ºÎºÐ ¹®ÀÚ¿­ÀÇ ½ÃÀÛÀ» Ç¥½ÃÇÏ´Â ¿É¼Â(1ºÎÅÍ ½ÃÀÛ)ÀÌ°í, ¼¼¹ø°´Â ºÎºÐ ¹®ÀÚ¿­ÀÇ ±æÀÌÀÌ´Ù.

random

ÀÌ°ÍÀº ÇÔ¼ö°¡ ¾Æ´Ï¶ó ¼Ó¼ºÀÌ´Ù. ÀÌ °ÍÀº 0.0~1.0 »çÀÌÀÇ ¶õ¼ö¸¦ »ý¼ºÇϴµ¥ »ç¿ëµÇ´Â SQL ¹®(¹®ÀÚ¿­).

Param($name )

¹ÙÀÎµå º¯¼ö¸¦ ´Ù¸¥ DB¿Í ȣȯµÇ°Ô »ý¼ºÇÑ´Ù. ´ëºÎºÐÀÇ µ¥ÀÌŸº£À̽ºÀÇ °æ¿ì ¹ÙÀÎµå ¸Å°³º¯¼ö´Â "?"ÀÌ´Ù. ±×·¯³ª ¸î¸î µ¥ÀÌŸº£À̽ºÀÇ °æ¿ì À̸§À» °®´Â ¹ÙÀÎµå º¯¼ö¸¦ »ç¿ëÇÑ´Ù. ¿¹¸¦µé¾î Oracle °æ¿ì À̸§À» °®´Â ¹ÙÀÎµå º¯¼ö ":somevar"¸¦ »ç¿ëÇÑ´Ù. ÀÌ ÇÔ¼ö·Î ¹ÙÀÎµå ¸Å°³º¯¼ö¸¦ °®´Â SQL ¹®À» ´Ù¸¥ DB¿Í ȣȯ°¡´ÉÇÏ°Ô Á¤ÀÇÇÒ ¼ö ÀÖ´Ù:

$sql = 'insert into table (col1,col2) values ('.$DB->Param('a').','.$DB->Param('b').')';
# 'insert into table (col1,col2) values (?,?)'
# ¶Ç´Â 'insert into table (col1,col2) values (:a,:b) »ý¼º'
$stmt = $DB->Prepare($sql);
$stmt = $DB->Execute($stmt,array('one','two'));

PrepareSP($sql)

mssql°ú oci8¿¡¼­ ÀúÀåµÈ ÇÁ·Î½ÃÁ®¸¦ È£ÃâÇϸ鼭 Á÷Á¢ ¸Å°³º¯¼ö¿Í ¸®ÅÏ°ªÀ» ¹ÙÀεåÇÏ±æ ¿øÇÒ¶§(ƯÈ÷ LOB¸¦ ó¸®ÇÒ ¶§) PrepareSP()·Î ÀÌ ÀÛ¾÷À» ¼öÇàÇÒ ¼ö ÀÖ´Ù.

À§ÀÇ Prepare( )¿Í µ¿ÀÏÇÑ ¹è¿­À̳ª $sql ¹®ÀÚ¿­À» ¸®ÅÏÇÑ´Ù. ¸¸¾à ¸®ÅÏ°ªÀ» ¹ÙÀεåÇÒ ÇÊ¿ä°¡ ¾ø´Ù¸é ÀÌ ÇÔ¼ö ´ë½Å¿¡ Prepare¸¦ »ç¿ëÇØ¾ß ÇÑ´Ù.

PrepareSP( )ÀÇ »ç¿ë¿¹´Â ¾Æ·¡ÀÇ Parameter( )À» º¸±â ¹Ù¶õ´Ù.

ÁÖÀÇ: mssql µå¶óÀ̹ö¿¡¼­ ÀúÀåµÈ ÇÁ·Î½ÃÀú¸¦ Áغñ(ÄÄÆÄÀÏ)ÇÏ´Â °ÍÀº Ưº°ÇÑ ÇÔ¼ö, mssql_init( ) È£ÃâÀ» ÇÊ¿ä·Î ÇÑ´Ù. PrepareSP( )´Â ¸ðµç ´Ù¸¥ µå¶óÀ̹ö¿¡¼­ »ç¿ëÇÒ ¼ö ÀÖÀ¸¸ç, Prepare( )¸¦ È£ÃâÇÔÀ¸·Î¼­ ¿¡¹Ä·¹À̼ǵȴÙ.

Parameter($stmt, $var, $name, $isOutput=false, $maxLen = 4000, $type = false )

PrepareSP( )¸¦ »ç¿ëÇؼ­ SQL¹®À» Áغñ(ÄÄÆÄÀÏ)ÇÑ ÈÄ, ¹ÙÀÎµå ¸Å°³º¯¼ö¸¦ ¸®ÅÏ°ªÀ̳ª Ưº°ÇÑ µ¥ÀÌŸ ó¸®(LOB)¿¡ Àû´çÇÏ°Ô Ãß°¡ÇÑ´Ù. ÇöÀç mssql°ú oci8¿¡¼­¸¸ Áö¿øµÈ´Ù. ¸Å°³º¯¼ö´Â ´ÙÀ½°ú °°´Ù:

$stmt Prepare() ³ª PrepareSP()¿¡ÀÇÇØ ¸®ÅÏµÈ ¹®.
$var ¹ÙÀεåÇÒ PHP º¯¼ö. ¹Ýµå½Ã ¸ÕÀú ÃʱâÈ­ÇØ¾ß ÇÑ´Ù!
$name ¹ÙÀεåÇÒ ÀúÀåµÈ ÇÁ·Î½ÃÀúÀÇ º¯¼ö¸í.
[$isOutput] ¸Å°³º¯¼öÀÇ ¹æÇâÀ» Áö½Ã 0/false=IN 1=OUT 2=IN/OUT. oci8 µå¶óÀ̹ö´Â ¹æÇâÀ» ÀÚµ¿ °ËÃâÇϹǷΠoci8¿¡¼­´Â ¹«½ÃµÈ´Ù.
[$maxLen] ¸Å°³º¯¼öÀÇ ÃÖ´ë ±æÀÌ.
[$type] type¿¡´ëÇØ »ç¿ëÇÒ ¼ö ÀÖ´Â °ª¿¡´ëÇÑ º¸´Ù ÀÚ¼¼ÇÑ Á¤º¸´Â php.netÀÇ mssql_bind¿Í ocibindbyname ¹®¼­¸¦ º¸±â ¹Ù¶õ´Ù.

¿¹:

# @RETVAL = SP_RUNSOMETHING @myid,@group
$stmt = $db->PrepareSP('SP_RUNSOMETHING'); # ÁÖÀÇ: ¸Å°³º¯¼ö ¸íÀº @·Î ½ÃÀÛµÇÁö ¾ÊÀ½
$db->Parameter($stmt,$id,'myid'); $db->Parameter($stmt,$group,'group',false,64); # MSSQL¿¡¼­ ¸®ÅÏ°ª - RETVAL´Â ÇÁ·Î±×·¥¿¡ÀÇÇØ Á¤ÇØÁø À̸§ÀÓ $db->Parameter($stmt,$ret,'RETVAL',true);
$db->Execute($stmt);

oci8 ¿¹:

# ¿À¶óŬÀÇ °æ¿ì, Prepare¿Í PrepareSP´Â µ¿ÀÏÇÏ´Ù
$stmt = $db->PrepareSP(
	"declare RETVAL integer; 
	 begin 
		:RETVAL := SP_RUNSOMETHING(:myid,:group); 
	 end;");
$db->Parameter($stmt,$id,'myid');
$db->Parameter($stmt,$group,'group',false,64);
$db->Parameter($stmt,$ret,'RETVAL',true);
$db->Execute($stmt);

oci8°ú mssql ±¸Çö»óÀÇ À¯ÀÏÇÑ Â÷ÀÌ´Â $sqlÀÇ ¹®¹ýÀ̶ó´Â °ÍÀÌ ÁÖÀÇÇϱâ¹Ù¶õ´Ù.

mssql¿¡¼­ ¸¸¾à $type ¸Å°³º¯¼ö°¡ °ÅÁþÀ¸·Î ¼³Á¤µÇ¸é $type´Â Àü´ÞµÈ PHP º¯¼öÇü¿¡µû¶ó µ¿ÀûÀ¸·Î °áÁ¤µÈ´Ù(string => SQLCHAR, boolean =>SQLINT1, integer =>SQLINT4 ¶Ç´Â float/double=>SQLFLT8).

oci8¿¡¼­ $type´Â OCI_B_FILE (Binary-File), OCI_B_CFILE (Character-File), OCI_B_CLOB (Character-LOB), OCI_B_BLOB (Binary-LOB)°ú OCI_B_ROWID (ROWID)·Î ¼³Á¤µÉ ¼ö ÀÖ´Ù. ³ÎÀ» Àü´ÞÇϱâÀ§ÇØ $db->Parameter($stmt, $null=null, 'param')¸¦ »ç¿ëÇÑ´Ù.

¸¶Áö¸·À¸·Î oci8¿¡¼­ ¹ÙÀÎµå ¸Å°³º¯¼ö´Â PrepareSP( ) ³ª Parameters¸¦ ´Ù½Ã È£ÃâÇÏÁö¾Ê°í »ç¿ëÇÒ ¼ö ÀÖ´Ù. ÀÌ °ÍÀº mssql¿¡¼­´Â ºÒ°¡´ÉÇÏ´Ù. oci8 ¿¹:

$id = 0; $i = 0;
$stmt = $db->PrepareSP( "update table set val=:i where id=:id");
$db->Parameter($stmt,$id,'id');
$db->Parameter($stmt,$i, 'i');
for ($cnt=0; $cnt < 1000; $cnt++) {
	$id = $cnt; 
$i = $cnt * $cnt; # works with oci8! $db->Execute($stmt);
}

Bind($stmt, $var, $size=4001, $type=false, $name=false)

ÀÌ°ÍÀº oci8 µå¶óÀ̹ö¿¡¼­¸¸ Áö¿øµÇ´Â Àú¼öÁØ ÇÔ¼öÀÌ´Ù. ¿À¶óŬ¸¸ Áö¿øÇϱ⸦ ¿øÇÏ´Â °æ¿ì°¡ ¾Æ´Ï¶ó¸é »ç¿ëÇÏÁö ¾Ê´Â °ÍÀÌ ÁÁ´Ù. º¯¼ö¸¦ ¹ÙÀεåÇϴµ¥¿¡ Parameter( ) ÇÔ¼ö¸¦ »ç¿ëÇÒ °ÍÀ» ±Ç°íÇÑ´Ù.

Bind( ) ·Î SQL ¹®³»ÀÇ º¯¼ö¸¦ ¹ÙÀεåÇÒ ¼ö ÀÖ´Ù. ÀÌ ÇÔ¼ö·Î PHP º¯¼ö¸¦ Prepare( )¸¦ »ç¿ëÇؼ­ Áغñ(ÄÄÆÄÀÏ)µÈ ¿À¶óŬ SQL¹®¿¡ Á¤ÀÇµÈ À̸§À¸·Î ¹ÙÀεå ÇÒ ¼ö ÀÖ´Ù. ¿À¶óŬÀÇ À̸§À» °®´Â º¯¼ö´Â ÄÝ·Ð(:)À¸·Î ½ÃÀ۵Ǹç, ADOdb´Â :0, :1, :2, :3 µîÀ¸·Î È£ÃâµÇ´Â À̸§À» °®´Â º¯¼ö¸¦ ¿ä±¸ÇÑ´Ù. Bind( )ÀÇ Ã¹¹ø° È£ÃâÀº :0·Î ¸ÅÄ¡µÇ¸ç, µÎ¹ø° È£ÃâÀº :1 µîÀ¸·Î È£ÃâµÈ´Ù. ¹ÙÀεùÀº Insert, Select, Update¹®ÀÇ ¼Óµµ¸¦ 100% Áõ°¡½ÃŲ´Ù.

´Ù¸¥ º¯¼ö, $size´Â µ¥ÀÌŸ ½ºÅ丮Áö¿¡´ëÇÑ ¹öÆÛ Å©±â¸¦ ¼³Á¤ÇÑ´Ù. $type´Â ¿É¼ÇÀ¸·Î ¼­¼úÀÚ À¯Çü, OCI_B_FILE (Binary-File), OCI_B_CFILE (Character-File), OCI_B_CLOB (Character-LOB), OCI_B_BLOB (Binary-LOB)¿Í OCI_B_ROWID (ROWID)¸¦ ³ªÅ¸³½´Ù. ¸¶Áö¸·À¸·Î ±âº»ÀûÀÎ :0, :1, µîÀÇ À̸§À» »ç¿ëÇÏ´Â ´ë½Å¿¡ $name¸¦ »ç¿ëÇؼ­ ÀÚ½ÅÀÇ ¹ÙÀÎµå ¸íÀ» Á¤ÀÇÇÒ ¼ö ÀÖ´Ù.

´ÙÀ½ ¿¹´Â 3°³ÀÇ ¹ÙÀÎµå º¯¼ö, :p1, :p2, :p3¸¦ º¸ÀÌ°í ÀÖ´Ù. ÀÌ µé º¯¼ö´Â :0, :1, :2·Î ¹ÙÀεåµÈ´Ù.

$stmt = $DB->Prepare("insert into table (col0, col1, col2) values (:0, :1, :2)");
$DB->Bind($stmt, $p1);
$DB->Bind($stmt, $p2);
$DB->Bind($stmt, $p3);
for ($i = 0; $i < $max; $i++) { 
   $p1 = ?; $p2 = ?; $p3 = ?;
   $DB->Execute($stmt);
}

¶ÇÇÑ À̸§À» °®´Â º¯¼ö¸¦ »ç¿ëÇÒ ¼ö ÀÖ´Ù:

$stmt = $DB->Prepare("insert into table (col0, col1, col2) values (:name0, :name1, :name2)");
$DB->Bind($stmt, $p1, "name0");
$DB->Bind($stmt, $p2, "name1");
$DB->Bind($stmt, $p3, "name2");
for ($i = 0; $i < $max; $i++) { 
   $p1 = ?; $p2 = ?; $p3 = ?;
   $DB->Execute($stmt);
}

LogSQL($enable=true)

SQL ·Î±ë°ú ŸÀÌ¹Ö ÇÔ¼ö(fnExecute¸¦ »ç¿ë)¸¦ ¼³Ä¡ÇϱâÀ§ÇØ ÀÌ ¸Þ¼Òµå¸¦ È£ÃâÇÑ´Ù. ±×·¯¸é ¸ðµç SQL¹®ÀÌ Å×ÀÌŸº£À̽ºÀÇ adodb_logsql Å×ÀÌºí¿¡ ±â·ÏµÈ´Ù. ¸¸¾à adodb_logsql Å×À̺íÀÌ Á¸ÀçÇÏÁö ¾Ê´Â´Ù¸é ADOdb´Â Å×À̺íÀ» »ý¼ºÇϰԵȴÙ. ¹°·Ð »ç¿ëÀÚ´Â Å×ÀÌºí »ý¼º ±ÇÇÑÀÌ ÀÖ¾î¾ß ÇÑ´Ù. ÀÌÀü¿¡ ±â·ÏµÈ °ªÀÌ ¸®ÅϵȴÙ(»ç¿ëÁßÀÏ °Ü¿ì Âü, ±×·¸Áö ¾ÊÀ» °æ¿ì °ÅÁþ). ´ÙÀ½Àº ¸î¸î µ¥ÀÌŸ º£À̽º¿¡´ëÇÑ DDLÀÇ ¿¹ÀÌ´Ù:

		mysql:
		CREATE TABLE adodb_logsql (
		  created datetime NOT NULL,
		  sql0 varchar(250) NOT NULL,
		  sql1 text NOT NULL,
		  params text NOT NULL,
		  tracer text NOT NULL,
		  timer decimal(16,6) NOT NULL
		)
		
		postgres:
		CREATE TABLE adodb_logsql (
		  created timestamp NOT NULL,
		  sql0 varchar(250) NOT NULL,
		  sql1 text NOT NULL,
		  params text NOT NULL,
		  tracer text NOT NULL,
		  timer decimal(16,6) NOT NULL
		)
		
		mssql:
		CREATE TABLE adodb_logsql (
		  created datetime NOT NULL,
		  sql0 varchar(250) NOT NULL,
		  sql1 varchar(4000) NOT NULL,
		  params varchar(3000) NOT NULL,
		  tracer varchar(500) NOT NULL,
		  timer decimal(16,6) NOT NULL
		)
		
		oci8:
		CREATE TABLE adodb_logsql (
		  created date NOT NULL,
		  sql0 varchar(250) NOT NULL,
		  sql1 varchar(4000) NOT NULL,
		  params varchar(4000),
		  tracer varchar(4000),
		  timer decimal(16,6) NOT NULL
		)
»ç¿ë¿¹:
	$conn->LogSQL(); // ·Î±ë Äѱâ
	  :
	$conn->Execute(...);
	  :
	$conn->LogSQL(false); // ·Î±ë ²ô±â
	
	# ·Î±×µÈ °á°úÀÇ ¿ä¾à Ãâ·Â
	$perf = NewPerfMonitor($conn);
	echo $perf->SuspiciousSQL();
	echo $perf->ExpensiveSQL();

·Î±ëÀÇ À¯ÀÏÇÑ Á¦ÇÑÀº SQL ·Î±ëÀ» ¸·´Â ·Ñ¹éÀÌ´Ù.

¶ÇÇÑ ¼º´É °¨½Ã¸¦ º¸±â¹Ù¶õ´Ù.

fnExecute°ú fnCacheExecute ¼Ó¼º

ÀÌ µÎ°³ÀÇ ¼Ó¼ºÀ¸·Î ADOdb¿¡ÀÇÇØ Ã³¸®µÇ´Â ¸ðµç SQL¹®¿¡´ëÇØ º´¸ñÇÔ¼ö¸¦ Á¤ÀÇÇÒ ¼ö ÀÖ´Ù. ÀÌ ¼Ó¼ºÀ¸·Î Åë°èºÐ¼®°ú ÁúÀÇ ÀçÀÛ¼ºÀ» ¼öÇàÇÒ ¼ö ÀÖ´Ù.

fnExecuteÀÇ ¿¹

ÀÌ °ÍÀº fnExecuteÀ» »ç¿ëÇÏ´Â ¿¹·Î, ¸ðµç ij½¬µÈ ÁúÀÇ¿Í Ä³½¬µÇ¾ÊÀº ÁúÀǸ¦ °è»êÇϱâÀ§ÇØ ´ÙÀ½°ú °°ÀÌ ÇÒ ¼ö ÀÖ´Ù:

# $db ´Â Á¢¼Ó °³Ã¼
function CountExecs($db, $sql, $inputarray)
{
global $EXECS;

if (!is_array(inputarray)) $EXECS++;
# 2Â÷¿ø ÀÔ·Â ¹è¿­ ó¸®
else if (is_array(reset($inputarray))) $EXECS += sizeof($inputarray);
else $EXECS++;
}

# $db´Â Á¢¼Ó°³Ã¼
function CountCachedExecs($db, $secs2cache, $sql, $inputarray)
{
global $CACHED; $CACHED++; }
$db = NewADOConnection('mysql'); $db->Connect(...); $db->fnExecute = 'CountExecs'; $db->fnCacheExecute = 'CountCachedExecs'; : :
# ¸¹Àº SQL ¹® ½ÇÇàÈÄ:` printf("<p>ÅäÅ» ÁúÀÇ=%d; ij½¬=%d</p>",$EXECS+$CACHED, $CACHED);

fnExecute ÇÔ¼ö´Â SQLÀÌ Çؼ®/½ÇÇàµÇ±â Àü¿¡ È£ÃâµÇ¹Ç·Î ÁúÀÇ ÀçÀÛ¼ºÀ» ¼öÇàÇÒ ¼ö ÀÖ´Ù. ¸¸¾à Áغñ(ÄÄÆÄÀÏ)µÈ ¹®Àå¿¡ Àü´ÞµÇ´Â °æ¿ì $sqlÀº ¹è¿­ÀÌ µÈ´Ù(Prepare ÂüÁ¶). fnCacheExecute ÇÔ¼ö´Â ¸®ÅÏµÈ ·¹ÄÚµå¼ÂÀÌ Ä³½¬µÈ °æ¿ì¿¡¸¸ È£ÃâµÈ´Ù. ÇÔ¼ö ¸Å°³º¯¼ö´Â °¢°¢ Execute¿Í CacheExecute¿Í ¸ÅÄ¡µÈ´Ù. ´Ü $this(Á¢¼Ó °³Ã¼)°¡ ù¹ø° ¸Å°³º¯¼ö·Î Àü´ÞµÈ °æ¿ì´Â ¿¹¿Ü·Î ÇÑ´Ù.

ADOdb 3.91 ÀÌÈĹöÀü¿¡¼­ fnExecuteÀÇ µ¿ÀÛÀº Á¤ÀÇµÈ ÇÔ¼ö°¡ ¸®ÅÏÇÏ´Â °ªÀÌ ¹«¾úÀ̳Ŀ¡µû¶ó ´Þ¶óÁø´Ù. ¸¸¾à °ªÀ» ¸®ÅÏÇÏÁö ¾Ê´Â´Ù¸é $sqlÀÌ ½ÇÇàµÈ´Ù. ÀÌ °ÍÀº ÁúÀÇ ÀçÀÛ¼ºÀ̳ª SQL ÁúÀÇ °è»ê¿¡ À¯¿ëÇÏ´Ù.

´Ù½Ã ¸»Çϸé Execute ÇÔ¼ö¸¦ ÀÚ½ÅÀÌ ¼³°èÇÑ ÇÔ¼ö·Î ±³Ã¼ÇÏ±æ ¿øÇÑ´Ù°í ÇÏÀÚ. ¸¸¾à ÀÌ °æ¿ì¶ó¸é ÀÚ½ÅÀÌ ¼³°èÇÑ ÇÔ¼ö´Â °ªÀ» ¸®ÅÏÇÏ¸é µÈ´Ù. °ªÀÌ ¸®ÅϵǸé ÀÌ °ªÀº ¾î¶°ÇÑ Ã³¸®µµ °ÅÄ¡Áö ¾ÊÀºÃ¼ Áï½Ã ¸®ÅϵȴÙ. ÀÌ °ÍÀº ³»ºÎÀûÀ¸·Î ADOdb¿¡¼­ LogSQL( ) ÇÔ¼ö¸¦ ±¸ÇöÇϴµ¥ »ç¿ëµÇ¾ú´Ù.


ADOConnection À¯Æ¿¸®Æ¼ ÇÔ¼ö

BlankRecordSet([$queryid])

»ç¿ëÇÒ ¼ö ¾øÀ½ - 1.99¿¡¼­ Á¦°ÅµÊ.

Concat($s1,$s2,....)

$s1, $s2µîÀ» ¿¬°áÇϴµ¥ »ç¿ëµÇ´Â SQL ¹®ÀÚ¿­À» »ý¼ºÇÑ´Ù. ¹®ÀÚ¿­ ¿¬°áÀ» »õ¼ºÇϱâÀ§ÇØ concat_operator ÇʵåÀÇ ¹®ÀÚ¿­À» »ç¿ëÇÑ´Ù. ¿¬°á ¿¬»êÀÚ°¡ »ç¿ëµÇÁö¾ÊÀ¸¸é ÀÌ ÇÔ¼ö´Â ÁßøµÈ´Ù. ¿¹: MySQL

¿¬°áµÈ ¹®ÀÚ¿­À» ¸®ÅÏÇÑ´Ù.

DBDate($date)

$date¸¦ µ¥ÀÌŸº£À̽º°¡ Çã¿ëÇÏ´Â Çü½ÄÀ¸·Î º¯È¯ÇÑ´Ù. ÀÌ °ÍÀº INSERT/UPDATE¹®¿¡¼­ »ç¿ëµÈ´Ù. SELECT ¹®ÀÇ °æ¿ì SQLDate¸¦ »ç¿ëÇÑ´Ù. $date ¸Å°³º¯¼ö´Â À¯´Ð½ºÀÇ Á¤¼ö ŸÀÓ½ºÅÆÇÁ³ª ISO Çü½Ä Y-m-d Àϼö ÀÖ´Ù. »ç¿ëµÇ´Â Çü½ÄÀ» À¯ÁöÇϱâÀ§ÇØ fmtDate Çʵ带 »ç¿ëÇÑ´Ù. ¸¸¾à ³ÎÀ̳ª °ÅÁþ ¶Ç´Â ''°¡ Àü´ÞµÇ¸é SQL ³Î·Î º¯È¯µÈ´Ù.

ÀοëµÈ ³¯Â¥¸¦ ¸®ÅÏÇÑ´Ù.

DBTimeStamp($ts)

ŸÀÓ½ºÅÆÇÁ $ts¸¦ µ¥ÀÌŸº£À̽º°¡ Çã¿ëÇÏ´Â Çü½ÄÀ¸·Î º¯È¯ÇÑ´Ù. ÀÌ °ÍÀº À¯´Ð½ºÀÇ Á¤¼ö ŸÀ̽ºÅÆÇÁ³ª ISO Çü½Ä Y-m-d H:i:s ÀÏ ¼ö ÀÖ´Ù. »ç¿ëµÇ´Â Çü½ÄÀ» À¯ÁöÇϱâÀ§ÇØ fmtTimeStamp Çʵ带 »ç¿ëÇÑ´Ù. ¸¸¾à ³ÎÀ̳ª °ÅÁþ ¶Ç´Â ''°¡ Àü´ÞµÇ¸é SQL ³Î·Î º¯È¯µÈ´Ù.

ÀοëµÈ ¹®ÀÚ¿­·Î ŸÀÓ½ºÅÆÇÁ¸¦ ¸®ÅÏÇÑ´Ù.

qstr($s,[$magic_quotes_enabled=false])

µ¥ÀÌŸº£À̽º¿¡ Àü¼ÛµÉ ¹®ÀÚ¿­À» ÀοëÇÑ´Ù. $magic_quotes_enabled ¸Å°³º¯¼ö´Â À峭ó·³ º¸ÀÌÁö¸¸ POST/GET º¯¼ö¿¡¼­ ÃßÃßµÈ ¹®ÀÚ¿­À» ÀοëÇÏ°í, ÀÌ °ªÀ» get_magic_quotes_gpc()ÀÇ µÎ¹ø° ¸Å°³º¯¼ö·Î Àü´ÞÇÏ´Â °æ¿ì À¯¿ëÇÏ´Ù. ÀÌ °ÍÀ¸·Î º¯¼ö¸¦ µÎ¹ø ÀοëÇÏ´Â °Í(qstr¿¡ÀÇÇØ Çѹø, magic_quotes_gpcÀÇÇØ Çѹø)À» È®½ÇÈ÷ ¸·À» ¼ö ÀÖ´Ù.

¿¹. $s = $db->qstr(HTTP_GET_VARS['name'],get_magic_quotes_gpc());

ÀοëµÈ ¹®ÀÚ¿­À» ¸®ÅÏÇÑ´Ù.

Quote($s)

¹®ÀÚ¿­ $s¸¦ ÀοëÇÏ°í, µ¥ÀÌŸº£À̽º¿¡¼­ »ç¿ëµÇ´Â ÀÎ¿ë ¹®ÀÚ¸¦ Àû´çÈ÷ À̽ºÄÉÀÌÇÁÇÑ´Ù. ÀÌÀü¿¡´Â Magic Quote ¼³Á¤À» °Ë»çÇßÁö¸¸ ÀÌ °ÍÀº PEAR DB¿ÍÀÇ È£È¯¼º¶§¹®¿¡ 3.31¿¡¼­ Á¦°ÅµÇ¾ú´Ù.

Affected_Rows( )

Update ¶Ç´Â Delete ¹®¿¡ÀÇÇØ ¿µÇâÀ» ¹ÞÀº ÇàÀÇ ¼ö¸¦ ¸®ÅÏÇÑ´Ù. ÀÌ ±â´ÉÀÌ Áö¿øµÇÁö¾Ê´Â °æ¿ì °ÅÁþÀÌ ¸®ÅϵȴÙ.

interbase/firebird´Â ÇöÀç Áö¿øµÇÁö¾Ê´Â´Ù

Insert_ID( )

InsertµÈ ¸¶Áö¸· ÀÚµ¿Áõ°¡ ID°¡ ¸®ÅϵȴÙ. ÀÌ ±â´ÉÀÌ Áö¿øµÇ¾Ê´Â °æ¿ì °ÅÁþÀÌ ¸®ÅϵȴÙ.

ÀÚµ¿Áõ°¡³ª °³Ã¼ ID¸¦ Áö¿øÇÏ´Â µ¥ÀÌŸº£À̽º, PostgreSQL, MySQL, MSSQL¸¸ Áö¿øµÈ´Ù. PostgreSQLÀº OID¸¦ ¸®ÅÏÇϸç, OID´Â µ¥ÀÌŸº£À̽º¸¦ ´Ù½Ã ·ÎµåÇÑ °æ¿ì º¯°æµÉ ¼ö ÀÖ´Ù.

RowLock($table,$where)

Æ®·£Àè¼Çµ¿¾È Å×À̺í ÇàÀ» Àá±Ù´Ù. ´ÙÀ½Àº table1ÀÇ ·¹ÄÚµå $id¸¦ Àá±×´Â ¿¹ÀÌ´Ù:

	$DB->StartTrans();
	$DB->RowLock("table1","rowid=$id");
	$DB->Execute($sql1);
	$DB->Execute($sql2);
	$DB->CompleteTrans();

db2, interbase, informix, mssql, oci8, postgres, sybase¿¡¼­ Áö¿øµÈ´Ù.

MetaDatabases()

¼­¹ö¿¡¼­ »ç¿ëÇÒ ¼ö ÀÖ´Â ¸ðµç µ¥ÀÌŸº£À̽ºÀÇ ¸ñ·ÏÀ» ¹è¿­·Î ¸®ÅÏÇÑ´Ù. ¸ÕÀú ¼­¹ö¿¡ Á¢¼ÓÇØ¾ß Çϸç, ODBC, MySQL, ADO¿¡¼­ »ç¿ëÇÒ ¼ö ÀÖ´Ù.

MetaTables($ttype = false, $showSchema = false, $mask=false)

ÇöÀç µ¥ÀÌŸº£À̽º¿¡¼­ »ç¿ëÇÒ ¼ö ÀÖ´Â Å×À̺í°ú ºä¸¦ ¹è¿­·Î ¸®ÅÏÇÑ´Ù. ÀÌ ¹è¿­¿¡´Â °¡´ÉÇÏ´Ù¸é Ä«´Þ·Î±× Å×À̺íÀº Á¦¿ÜµÈ´Ù. Å×ÀÌºí¸¸ º¸±âÀ§Çؼ­´Â $db->MetaTables('TABLES')¸¦ »ç¿ëÇÑ´Ù. ºä¸¸ º¸±âÀ§Çؼ­´Â $db->MetaTables('VIEWS')¸¦ »ç¿ëÇÑ´Ù. $showSchema ¸Å°³º¯¼ö´Â ÇöÀç DB2¿¡¼­¸¸ µ¿ÀÛÇÑ´Ù. ÀÌ °ªÀ» ÂüÀ¸·Î ¼³Á¤ÇÏ¸é ½ºÅ°¸¶ À̸§¿¡ Å×ÀÌºí¿¡ Ãß°¡µÈ´Ù. ¿¹: "SCHEMA.TABLE".

¶ÇÇÑ ¸Å½ºÅ©¸¦ ÁöÁ¤ÇÒ ¼ö ÀÖ´Ù. ¿¹¸¦µé¾î $mask = 'TMP%'·Î ¼³Á¤Çϸé 'TMP'·Î ½ÃÀ۵Ǵ ¸ðµç Å×ÀÌºí¸¸ ¸®ÅϵȴÙ. ÇöÀç mssql, oci8, odbc_mssql°ú postgre+¸¸ $mask¸¦ Áö¿øÇÑ´Ù.

MetaColumns($table)

$tableÀÇ °¢ Ä÷³¿¡´ëÇÑ ÇϳªÀÇ ÇÊµå °³Ã¼(ADOFieldObject)ÀÇ ¹è¿­À» ¸®ÅÏÇÑ´Ù. ÇöÀç Sybase´Â Å×ÀÌŸ ÇüÀÇ ÀνÄÀ» Áö¿øÇÏÁö ¾ÊÀ¸¸ç ADO´Â ¿Ã¹Ù¸¥ µ¥ÀÌŸ ŸÀÔÀ» È®ÀÎÇÒ ¼ö ¾ø´Ù(µû¶ó¼­ ±âº» varcharÀ» °®´Â´Ù).

MetaColumnNames($table)

$table¿¡´ëÇÑ ÄÄ·³¸íÀÇ ¹è¿­À» ¸®ÅÏÇÑ´Ù.

MetaPrimaryKeys($table, $owner=false)

$tableÀÇ ÇÁ¶óÀ̸Ӹ® Å° Ä÷³ÀÇ À̸§À» ¹è¿­·Î ¸®ÅÏÇÑ´Ù. ÇöÀç mysql, odbc(db2, odbc_mssql Æ÷ÇÔ), mssql, postgres, interbase/firebird, oci8 ¿¡ÀÇÇØ Áö¿øµÈ´Ù.

ServerInfo($table)

µÎ°³ÀÇ ¿ä¼Ò, '¼³¸í'°ú '¹öÀü'À» Æ÷ÇÔÇÏ´Â ¹è¿­À» ¸®ÅÏÇÑ´Ù. '¼³¸í'Àº µ¥ÀÌŸº£À̽º¿¡´ëÇÑ ¼³¸íÀ» Æ÷ÇÔÇÏ°í ÀÖ´Ù. '¹öÀü'Àº º»ÁúÀûÀ¸·Î ¹öÀü ¹øÈ£¸¦ °¡Áö°í ÀÖ´Ù(À̶ÇÇÑ ¹®ÀÚ¿­ÀÌ´Ù).

MetaForeignKeys($table, $owner=false, $upper=false)

¿Ü·¡Å°ÀÇ ¿¬°ü¹è¿­À» ¸®ÅÏÇϰųª Áö¿øµÇÁö¾Ê´Â °æ¿ì °ÅÁþÀ» ¸®ÅÏÇÑ´Ù. ¿¹¸¦µé¾î Employee Å×À̺íÀº dept_table.deptid¸¦ Áö½ÃÇÏ´Â ¿Ü·¡Å°, employee.deptkey¸¦ °¡Áö°í ÀÖ°í employee.posn=posn_table.postionid¿Í employee.poscategory=posn_table.category ¶ó¸é $conn->MetaForeignKeys('employee')´Â ´ÙÀ½ °á°ú¸¦ ¸®ÅÏÇÑ´Ù

	array(
		'dept_table' => array('deptkey=deptid'),
		'posn_table' => array('posn=positionid','poscategory=category')
	)

Ãß°¡ÀûÀÎ ½ºÅ°¸¶³ª ¼ÒÀ¯ÁÖ´Â $owner¿¡¼­ Á¤ÀÇÇÒ ¼ö ÀÖ´Ù. ¸¸¾à $upper°¡ ÂüÀ̸é Å×ÀÌºí ¸í(¹è¿­ÀÇ Å°)Àº ´ë¹®ÀÚ°¡ µÈ´Ù.


ADORecordSet

SQL ¹®ÀÌ ADOConnection->Execute($sql)¿¡ÀÇÇØ ¼º°øÀûÀ¸·Î ¼öÇàµÇ¸é ADORecordSet °³Ã¼°¡ ¸®ÅϵȴÙ. ÀÌ °³Ã¤´Â °¡»ó Ä¿¼­¸¦ Æ÷ÇÏÇÏ°í ÀÖÀ¸¹Ç·Î Çà¿¡¼­ ÇàÀ¸·Î À̵¿ÇÒ ¼ö ÀÖÀ¸¸ç, Ä÷³°ú Ä÷³ ŸÀÔ¿¡´ëÇÑ Á¤º¸¸¦ ±¸ÇÒ ¼ö ÀÖ°í º¸Á¶ ÇÔ¼ö·Î »ç¿ëÀÚ¿¡°Ô º¸¿©Áú °á°ú¸¦ ó¸®ÇÒ ¼öµµ ÀÖ´Ù.

ADORecordSet Fields

fields: ÇöÀç ÇàÀ» Æ÷ÇÔÇÏ´Â ¹è¿­. ÀÌ °ÍÀº ¿¬°ü¹è¿­ÀÌ ¾Æ´Ï¸ç, 0¿¡¼­ºÎÅÍ columns-1±îÁö ¹øÈ£·Î ÂüÁ¶ÇÒ ¼ö ÀÖ´Â ¹è¿­ÀÌ´Ù. ¶ÇÇÑ ¿¬°ü¹è¿­Ã³·³ µ¿ÀÛÇÏ´Â ÇÔ¼ö Fields¸¦ º¸±â ¹Ù¶õ´Ù

dataProvider: µ¥ÀÌŸº£À̽º ¿¬°á¿¡ »ç¿ëµÈ ¸ÞÄ«´ÏÁò. ÀϹÝÀûÀ¸·Î odbc ³ª ado¸¦ »ç¿ëÇÏ´Â °æ¿ì¸¦ Á¦¿ÜÇÏ°í native·Î ¼³Á¤µÈ´Ù.

blobSize: Blob(Blob´Â TEXTAREA ű׿¡¼­ »ç¿ëµÇ´Â °Í°ú°°Àº ´ë¿ë·® ¹®ÀÚ¿­)·Î 󸮵DZâ ÀüÀÇ char, String, Varchar °³Ã¼ÀÇ ÃÖ´ë Å©±â. MetaType ÇÔ¼ö¸¦ º¸±â ¹Ù¶õ´Ù.

sql: ÀÌ ·¹ÄÚµå¼ÂÀ» »ý¼ºÇϴµ¥ »ç¿ëµÈ SQL »óŸ¦ °¡Áö°í ÀÖ´Ù.

canSeek: Move( ) ÇÔ¼ö°¡ µ¿ÀÛÇϸé ÂüÀ¸·Î ¼³Á¤µÈ´Ù.

EOF: Ä¿¼­°¡ ¸¶Áö¸· ·¹Äڵ带 Áö³ª¸é Âü.

ADORecordSet ÇÔ¼ö

ADORecordSet( )

»ý¼ºÀÚ. ÀϹÝÀûÀ¸·Î ÀÌ ÇÔ¼ö¸¦ È£ÃâÇÏ´Â °æ¿ì´Â ¾ø´Ù.

GetAssoc([$force_array])

·¹ÄÚµå¼ÂÀ¸·ÎºÎÅÍ ¿¬°ü¹è¿­À» »ý¼ºÇÑ´Ù. ÁÖÀÇ: ÀÌ ÇÔ¼ö´Â Á¢¼Ó °³Ã¼¿¡¼­µµ »ç¿ëÇÒ ¼ö ÀÖ´Ù. º¸´Ù ÀÚ¼¼ÇÑ Á¤º¸´Â Á¢¼Ó °³Ã¼¿¡¼­ ãÀ» ¼ö ÀÖ´Ù.

GetArray([$number_of_rows])

ÇöÀç Ä¿¼­ À§Ä¡¿¡¼­ºÎÅÍ ·¹ÄÚµåÀÇ 2Â÷¿ø ¹è¿­À» ¸¸µç´Ù. ÀÌ ¹è¿­Àº 0¿¡¼­ºÎÅÍ $number_of_rows-1±îÁö ¹øÈ£·Î ÂüÁ¶ÇÒ ¼ö ÀÖ´Ù. $number_of_rows°¡ Á¤ÀǵÇÁö ¾ÊÀ¸¸é EOF±îÁö ÂüÁ¶ÇÒ ¼ö ÀÖ´Ù.

GetRows([$number_of_rows])

ÇöÀç Ä¿¼­ À§Ä¡¿¡¼­ºÎÅÍ ·¹ÄÚµåÀÇ 2Â÷¿ø ¹è¿­À» ¸¸µç´Ù. Microsoft ADO¿Í ȣȯÀ» À§ÇØ ¸¸µç ÇÔ¼ö·Î GetArray()¿Í µ¿ÀÏÇÑ ÇÔ¼öÀÌ´Ù.

GetMenu($name, [$default_str=''], [$blank1stItem=true], [$multiple_select=false], [$size=0], [$moreAttr=''])

HTML ¸Þ´º(<select><option><option></select>)¸¦ »ý¼ºÇÑ´Ù. ·¹ÄÚµå¼ÂÀÇ Ã¹ Ä÷³(fields[0])´Â OPTION ű׷ΠÃâ·ÂµÉ ¹®ÀÚ¿­ÀÌ´Ù. ·¹ÄÚµå¼ÂÀÌ Çϳª ÀÌ»óÀÇ Ä÷³À» °®´Â´Ù¸é µÎ¹ø° Ä÷³(fields[1])Àº À¥¼­¹ö·Î Àü¼ÛµÇ´Â °ªÀ̵ȴÙ. ¸Þ´ºÀÇ À̸§Àº $name·Î ÁÙ ¼ö ÀÖ´Ù.

$default_strÀ» Á¤ÀÇÇÏ°í $default_str == fields[0]¶ó¸é ÀÌ Çʵ尡 ¼±ÅõȴÙ. $blank1stItemÀÌ ÂüÀ̶ó¸é ¿É¼Ç ű×ÀÇ Ã¹¹ø° Ç׸ñÀº ºó °ø¹éÀÌ µÈ´Ù. ¶ÇÇÑ $blank1stItem = "$value:$text"¸£ ¼³Á¤ÇÔÀ¸·Î¼­ ¿É¼Ç ű×ÀÇ Ã¹¹ø° Ç׸ñÀ» ¼³Á¤ÇÒ ¼ö ÀÖ´Ù.

´ÙÁß ¼±Åà ¸ñ·Ï »óÀÚÀÇ °æ¿ì $Default_str¿¡ ¹è¿­À» ÁöÁ¤ÇÒ ¼ö ÀÖ´Ù.

¸ñ·Ï »óÀÚ¸¦ ¸¸µé±âÀ§ÇØ $size¿¡ 0ÀÌ ¾Æ´Ñ°ªÀ» ¼³Á¤ÇÑ´Ù(¶Ç´Â $default_str¿¡ ¹è¿­À» ÁöÁ¤ÇÑ´Ù). $multiple_select°¡ ÂüÀ̸é $size Ç׸ñ¸¸Å­ÀÇ ¸ñ·Ï »óÀÚ°¡ ¸¸µé¾î Áø´Ù. $size==0À̸é 5°³ÀÇ Ç׸ñÀ» °®´Â ¸ñ·Ï »óÀÚ°¡ ¸¸µé¾îÁø´Ù. ±×ÈÄ ¹è¿­ÀÌ ¼­¹ö·Î ¸®ÅϵȴÙ. ¸¶Áö¸·À¸·Î Javascipt³ª Styles¿Í °°Àº Ãß°¡ÀûÀÎ ¼Ó¼ºÀ» Ãß°¡ÇϱâÀ§ÇØ $moreAttr ¸¦ »ç¿ëÇÑ´Ù.

¸Þ´º ¿¹ 1: GetMenu('menu1','A',true)´Â ´ÙÀ½°ú °°Àº ¸Þ´º¸¦ »ý¼ºÇÒ °ÍÀÌ´Ù: ¿©±â¼­ µ¥ÀÌŸ´Â (A,1), (B,2), (C,3)·Î ¼³Á¤µÇ¾ú´Ù. ¶ÇÇÑ ¿¹ 5¸¦ º¸±â¹Ù¶õ´Ù.

¸Þ´º ¿¹ 2: µ¿ÀÏÇÑ µ¥ÀÌŸ¿¡´ëÇØ, GetMenu('menu1',array('A','B'),false) ´Â A¿Í B°¡ ¼±ÅÃµÈ ¸Þ´º¸¦ »ý¼ºÇÒ °ÍÀÌ´Ù:

GetMenu2($name, [$default_str=''], [$blank1stItem=true], [$multiple_select=false], [$size=0], [$moreAttr=''])

ÀÌ °ÍÀº °ÅÀÇ GetMenu¿Í µ¿ÀÏÇÏÁö¸¸ $default_strÀÌ fields[1](¿É¼Ç ű×ÀÇ °ª)°ú ¸ÅÄ¡µÈ´Ù´Â °ÍÀÌ ´Ù¸£´Ù.

¸Þ´º ¿¹ 3: ¸Þ´º ¿¹ 2¿¡¼­ ÁÖ¾îÁø µ¥ÀÌŸ, GetMenu2('menu1',array('1','2'),false) ´Â ¸Þ´º ¿¹ 2¿¡¼­ ¼±ÅÃµÈ A¿Í B°¡ ¼±ÅÃµÈ ¸Þ´º°¡ »ý¼ºµÈ´Ù. ±×·¯³ª ÀÌ ¹ø¿¡ ¼±Åà ±âÁØÀº 2¹ø° Ä÷³(À¥¼­¹ö·Î ¸®ÅϵǴ °ª)ÀÌ´Ù.

UserDate($str, [$fmt])

³¯Â¥ ¹®ÀÚ¿­ $strÀ» ´Ù¸¥ Çü½ÄÀ¸·Î º¯È¯ÇÑ´Ù. ³¯Â¥ Çü½ÄÀº Y-m-d ¶Ç´Â À¯´Ð½º ŸÀÓ½ºÅÆÇÁ Çü½ÄÀÌ´Ù. ±âº» $fmt´Â Y-m-d ÀÌ´Ù.

UserTimeStamp($str, [$fmt])

ŸÀÓ½ºÅÆÇÁ ¹®ÀÚ¿­ $str¸¦ ´Ù¸¥ Çü½ÄÀ¸·Î º¯È¯ÇÑ´Ù. ŸÀÓ½ºÅÆÇÁ Çü½ÄÀº '2002-02-28 23:00:12'¿¡¼­Ã³·³ Y-m-d H:i:sÀ̰ųª À¯´Ð½º ŸÀÓ½ºÅÆÇÁ Çü½ÄÀÌ´Ù. UserTimeStamp´Â $strÀ» Çؼ®ÇϱâÀ§ÇØ UnixTimeStampÀ» È£ÃâÇϸç, $fmt¸¦ Á¤ÀÇÇÏÁö¾ÊÀº °æ¿ì ±âº»°ª Y-m-d H:i:s°¡ µÈ´Ù.

UnixDate($str)

³¯Â¥ ¹®ÀÚ¿­ $str¸¦ Çؼ®ÇÏ°í À¯´Ð½º mktime Çü½Ä(¿¹: 1970³â 1¿ù 1ÀϺÎÅÍ ÇöÀç±îÁö¸¦ ÃʷΠȯ»êÇÑ ¼ýÀÚ)À¸·Î ¸®ÅÏÇÑ´Ù. ³¯Â¥´Â Y-m-d H:i:s Çü½ÄÀÏ °ÍÀÌ´Ù(¿¹¿Ü: Sybase¿Í Microsoft SQL ¼­¹ö). ¿©±â¼­ M d Y Çü½Ä ¶ÇÇÑ »ç¿ëÇÒ ¼ö ÀÖ´Ù(3±ÛÀڷΠǥÇöµÇ´Â ¿ù ¹®ÀÚ¿­Àº Àü¿ª º¯¼ö(Áö¿ªÈ­¿¡ ÇÊ¿äÇÑ)¿¡ÀÇÇØ Á¦¾îµÈ´Ù).

ÀÌ ÇÔ¼ö´Â ADORecordSet°ú ADOConnection¿¡¼­ »ç¿ëÇÒ ¼ö ÀÖ´Ù(1.91ÀÌ»ó).

UnixTimeStamp($str)

ŸÀÓ½ºÅÆÇÁ ¹®ÀÚ¿­ $str¸¦ Çؼ®ÇÏ°í À¯´Ð½º mktime Çü½Ä(¿¹: 1970³â 1¿ù 1ÀϺÎÅÍ ÇöÀç±îÁö¸¦ ÃʷΠȯ»êÇÑ ¼ýÀÚ)À¸·Î ¸®ÅÏÇÑ´Ù. ³¯Â¥´Â "Y-m-d, H:i:s" (1970-12-24, 00:00:00) ³ª "Y-m-d H:i:s" (1970-12-24 00:00:00) ³ª "YmdHis" (19701225000000)ÀÏ °ÍÀÌ´Ù(¿¹¿Ü: Sybase¿Í Microsoft SQL ¼­¹ö). ¿©±â¼­ "M d Y h:i:sA" (Dec 25 1970 00:00:00AM) ¶ÇÇÑ Çã¿ëµÈ´Ù(3±ÛÀڷΠǥÇöµÇ´Â ¿ù ¹®ÀÚ¿­Àº Àü¿ª º¯¼ö(Áö¿ªÈ­¿¡ ÇÊ¿äÇÑ)¿¡ÀÇÇØ Á¦¾îµÈ´Ù).

ADORecordSet°ú ADOConnection ¿¡¼­ »ç¿ëÇÒ ¼ö ÀÖ´Â ÇÔ¼ö(1.91ÀÌ»ó)

OffsetDate($dayFraction, $basedate=false)

$basedate¿¡´ëÇÑ °ú°Å/¹Ì·¡ÀÇ ³¯Â¥¸¦ °è»êÇϱâÀ§ÇÑ SQL ÇÔ¼ö(¹®ÀÚ¿­)À» ¸®ÅÏÇÑ´Ù. $basedate°¡ Á¤ÀǵÇÁö ¾ÊÀ¸¸é ÇöÀç ³¯Â¥°¡ »ç¿ëµÈ´Ù. Execute()¿¡ Àü´ÞµÉ ¶§ °è»êÀ» ¼öÇàÇÏ´Â SQL ¹®ÀÚ¿­ÀÌ ¸®ÅϵȴÙ.

¿¹¸¦µé¾î, ¿À¶óŬ¿¡¼­ ¿À´ÃºÎÅÍ 2.5ÀÏ ÈÄÀÇ ³¯Â¥¿Í ½Ã°£À» ã±âÀ§ÇØ ´ÙÀ½°ú °°ÀÌ »ç¿ëÇÒ ¼ö ÀÖ´Ù:

# Áö±Ý ºÎÅÍ ÇÑÁÖÀÇ ³¯Â¥¸¦ °¡Á®¿È
$fld = $conn->OffsetDate(7); // "(trunc(sysdate)+7")¸¦ ¸®ÅÏ
# ÇöÀç ÀϽ÷κÎÅÍ 60½Ã°£ Áö³­ ³¯Â¥¿Í ½Ã°£À» °¡Á®¿È
$fld = $conn->OffsetDate(2.5, $conn->sysTimeStamp);	// "(sysdate+2.5)"°¡ ¸®ÅϵÊ

$conn->Execute("UPDATE TABLE SET dodate=$fld WHERE ID=$id");

ÀÌ ÇÔ¼ö´Â mysql, mssql, oracle, oci8°ú postgresql µå¶óÀ̹ö¿¡¼­ »ç¿ëÇÒ ¼ö ÀÖ´Ù(2.13 ÀÌ»ó). ³¯Â¥ °è»êÀ» ¼öÇàÇÒ ¼ö ÀÖ´Â ´Ù¸¥ µå¶óÀ̹ö¿Íµµ µ¿ÀÛÇÒ ¼ö ÀÖ´Ù.

SQLDate($dateFormat, $basedate=false)

³¯Â¥³ª ³¯Â¥ Ä÷³ $basedate¸¦ Çü½Äº¯È¯ÇÒ ¼ö ÀÖ´Â µ¥ÀÌŸº£À̽º °íÀ¯ÀÇ SQL ÇÔ¼ö(¹®ÀÚ¿­)¸¦ ¸®ÅÏÇÑ´Ù. ÀÌ °ÍÀº SELECT ¹®¿¡¼­ »ç¿ëµÈ´Ù. INSERT/UPDATE ¹®ÀÇ °æ¿ì DBDate¸¦ »ç¿ëÇÑ´Ù. ÀÌ ÇÔ¼öÀÇ ³¯Â¥Çü½Ä, $dateFormat´Â ´ë¼Ò¹®ÀÚ¸¦ ±¸ºÐÇϸç, Áö¿øµÇ´Â °ªÀº ´ÙÀ½°ú °°´Ù:
 Y: 4 ÀÚ¸® ³âµµ
 Q: ºÐ±â (1-4)
 m: ¿ù (01-12)
 d: ÀÏ (01-31)
 H: 24½Ã (00-23)
 h: 12½Ã (1-12)
 i: ºÐ (00-59)
 s: ÃÊ (00-60)
 A: AM/PM Áö½Ã±â

ÀÌ¿ÜÀÇ ¸ðµç ´Ù¸¥ ±ÛÀÚ´Â ¹®Àڷμ­ ó¸®µÈ´Ù. ¶ÇÇÑ ±ÛÀÚ¸¦ À̽ºÄÉÀÌÇÁÇϱâÀ§ÇØ \¸¦ »ç¿ëÇÒ ¼ö ÀÖ´Ù. mysql, postgresql, mssql, oci8°ú DB2¸¦ Æ÷ÇÔÇÑ ¸î¸î µ¥ÀÌŸº£À̽º¿¡¼­ »ç¿ëÇÒ ¼ö ÀÖ´Ù.

ÀÌ ÇÔ¼ö´Â ´Ù¸¥ DB¿Í ȣȯ °¡´ÉÇÑ SQL ¹®(³¯Â¥·Î GROUP BYÇÏ´Â)À» ¾²´Âµ¥ À¯¿ëÇÏ´Ù. ´ÙÀ½ ¿¹´Â ºÐ±âº°·Î Æȸ° »óÇ°ÀÇ ÃÑ °¡°ÝÀ» Ãâ·ÂÇÏ´Â ¿¹ÀÌ´Ù(³¯Â¥´Â postdate¶ó´Â Çʵ忡 ÀúÀåµÈ´Ù).

 $sqlfn = $db->SQLDate('Y-\QQ','postdate'); # postdate¸¦ 2002-Q1·Î º¯È¯ÇÏ´Â SQL ¹®À» °¡Á®¿È
 $sql = "SELECT $sqlfn,SUM(cogs) FROM table GROUP BY $sqlfn ORDER BY 1 desc";
 

MoveNext( )

³»ºÎ Ä¿¼­¸¦ ´ÙÀ½ÇàÀ¸·Î À̵¿ÇÑ´Ù. $this->fields ¹è¿­Àº ÀÚµ¿ÀûÀ¸·Î °»½ÅµÈ´Ù. Ä¿¼­¸¦ À̵¿ÇÒ ¼ö ¾øÀ¸¸é(ÀϹÝÀûÀ¸·Î EOF¿¡ µµ´ÞÇÑ °æ¿ì), °ÅÁþÀÌ ¸®ÅϵǸç, ±×·¸Áö ¾ÊÀ¸¸é ÂüÀÌ ¸®ÅϵȴÙ.

¸¸¾à EOF¿¡ µµ´ÞÇϸé $this->fields ¹è¿­Àº °ÅÁþÀ¸·Î ¼³Á¤µÈ´Ù(ÀÌ °ÍÀº ADOdb 3.30 ÀÌÈÄÀÇ ¹öÀü¿¡¼­¸¸ ±¸ÇöµÇ¾ú´Ù.) 3.30 ÀÌÀü ¹öÀüÀÇ °æ¿ì $this->fields°¡ EOF¿¡ µµ´ÞÇϸé Àü¿ªº¯¼ö $ADODB_COMPAT_FETCH°¡ ÂüÀ¸·Î ¼³Á¤µÈ´Ù.

¿¹:

$rs = $db->Execute($sql);
if ($rs) 
	while (!$rs->EOF) {
 		ProcessArray($rs->fields);	
		$rs->MoveNext();
	} 

Move($to)

³»ºÎ Ä¿¼­¸¦ ÁöÁ¤µÈ Çà $toÀ¸·Î À̵¿ÇÑ´Ù. ÇàÀº 0ÇàºÎÅÍ ½ÃÀ۵ȴÙ. Áï, 0Àº ùÇàÀ» ³ªÅ¸³½´Ù. fields ¹è¿­Àº ÀÚµ¿ÀûÀ¸·Î °»½ÅµÈ´Ù. ³»ºÎÀûÀ¸·Î À̵¿À» Áö¿øÇÏÁö¾Ê´Â µ¥ÀÌŸº£À̽ºÀÇ °æ¿ì ADOdb´Â Àü¹æ À̵¿À» ½Ã¹Ä·¹ÀÌÆ®ÇÑ´Ù. ¸î¸î µ¥ÀÌŸº£À̽º´Â ÈĹæ À̵¿À» Áö¿øÇÏÁö¾Ê´Â´Ù. $to¸¦ EOF µÚ·Î ÁöÁ¤ÇÏ¸é ´ëºÎºÐÀÇ µ¥ÀÌŸº£À̽º¿¡¼­ $to´Â ·¹ÄÚµå¼ÂÀÇ ³¡À¸·Î À̵¿ÇÒ °ÍÀÌ´Ù. ODBC¸¦ »ç¿ëÇÏ´Â °æ¿ì ¸î¸î µ¥ÀÌŸº£À̽º´Â ÀÌ·¸°Ô µ¿ÀÛÇÏÁö ¾ÊÀ» ¼ö ÀÖ´Ù.

ÁÖÀÇ: ÀÌ ÇÔ¼ö´Â MicrosoftÀÇ ADO¿Í´Â ´Þ¸® Àý´ëÀ§Ä¡¸¦ »ç¿ëÇÑ´Ù.

Âü ¶Ç´Â °ÅÁþÀ» ¸®ÅÏÇÑ´Ù. °ÅÁþÀÌ¸é ´ëºÎºÐ ³»ºÎ Ä¿¼­°¡ À̵¿µÇÁö ¾ÊÀº °ÍÀ» ÀǹÌÇϸç, µû¶ó¼­ AbsolutePosition( )Àº Move( )¸¦ ½ÇÇàÇϱâÀüÀÇ ¸¶Áö¸· Ä¿¼­ÀÇ À§Ä¡¸¦ ¸®ÅÏÇÑ´Ù.

MoveFirst()

³»ºÎÀûÀ¸·Î Move(0)°¡ È£ÃâµÈ´Ù. ¸î¸î µ¥ÀÌŸº£À̽º´Â ÀÌ ÇÔ¼ö¸¦ Áö¿øÇÏÁö¾Ê´Â´Ù´Â °ÍÀ» ÁÖÀÇÇϱ⠹ٶõ´Ù.

MoveLast()

³»ºÎÀûÀ¸·Î Move(RecordCount()-1)ÀÌ È£ÃâµÈ´Ù. ¸î¸î µ¥ÀÌŸº£À̽º´Â ÀÌ ÇÔ¼ö¸¦ Áö¿øÇÏÁö¾Ê´Â´Ù´Â °Í¿¡ ÁÖÀÇÇϱ⠹ٶõ´Ù.

GetRowAssoc($toUpper=true)

ÇöÀçÇàÀ» Æ÷ÇÔÇÏ´Â ¿¬°ü¹è¿­À» ¸®ÅÏÇÑ´Ù. ¿¬°ü¹è¿­ÀÇ Å°´Â Ä÷³¸íÀÌ´Ù. Ä÷³¸íÀº ½±°Ô Á¢±ÙÇÒ ¼ö ÀÖµµ·Ï ´ë¹®ÀÚ¸¦ »ç¿ëÇÑ´Ù. ´ÙÀ½ ÇàÀ¸·Î À̵¿ÇϱâÀ§ÇØ MoveNext()¸¦ È£ÃâÇÒ ÇÊ¿ä°¡ ÀÖ´Ù.

¿¹:
Array ( [ID] => 1 [FIRSTNAME] => Caroline [LASTNAME] => Miranda [CREATED] => 2001-07-05 )

ÁÖÀÇ: $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC¿Í GetRowAssoc() ¸¦ ÇÔ²² »ç¿ëÇؼ­´Â ¾ÈµÈ´Ù. À̵éÀº µ¿ÀÏÇÑ ±â´ÉÀ» ÇϹǷΠ¼­·Î °£¼·À» ÀÏÀÇų ¼ö Àֱ⶧¹®ÀÌ´Ù.

AbsolutePage($page=-1)

ÇöÀç ÆäÀÌÁö¸¦ ¸®ÅÏÇÑ´Ù. PageExecute()/CachePageExecute()°¡ È£ÃâµÇ¾î¾ß ÇÑ´Ù. ÂüÁ¶: ¿¹ 8.

AtFirstPage($status='')

ù ÆäÀÌÁö(1 ÆäÀÌÁö)¸é ÂüÀ» ¸®ÅÏÇÑ´Ù. PageExecute()/CachePageExecute()°¡ È£ÃâµÇ¾î¾ß ÇÑ´Ù. ÂüÁ¶: ¿¹ 8.

AtLastPage($status='')

¸¶Áö¸· ÆäÀÌÁö(ùÆäÀÌÁö´Â 1)¸é ÂüÀ» ¸®ÅÏÇÑ´Ù. PageExecute()/CachePageExecute()°¡ È£ÃâµÇ¾î¾ß ÇÑ´Ù. ÂüÁ¶: ¿¹ 8.

Fields($colname)

ÇöÀç Çà¿¡´ëÇØ °ü·Ã Ä÷³ $colnameÀÇ °ªÀ» ¸®ÅÏÇÑ´Ù. Ä÷³¸íÀº ´ë¼Ò¹®ÀÚ¸¦ ±¸ºÐÇÑ´Ù.

ÀÌ ÇÔ¼ö´Â º¸Á¶ ÇÔ¼öÀÌ´Ù. º¸´Ù ³ôÀº ¼º´ÉÀ» ¿øÇÏ´Â °æ¿ì $ADODB_FETCH_MODE¸¦ »ç¿ëÇϱ⠹ٶõ´Ù.

FetchRow()

ÇöÀç ÇàÀ» Æ÷ÇÔÇÏ´Â ¹è¿­À̳ª EOF½Ã °ÅÁþÀ» ¸®ÅÏÇÑ´Ù. FetchRow( )´Â ³»ºÎÀûÀ¸·Î ÇöÀçÇàÀ» ¸®ÅÏÇÑ ÈÄ ´ÙÀ½ ·¹ÄÚµå·Î À̵¿ÇÑ´Ù.

°æ°í: FetchRow()¿Í MoveNext() ÇÔ²² »ç¿ëÇؼ­´Â ¾ÈµÈ´Ù.

»ç¿ë¿¹:

$rs = $db->Execute($sql);
if ($rs)
	while ($arr = $rs->FetchRow()) {
	     # process $arr	
	}

FetchInto(&$array)

ÇöÀç ÇàÀ» $array·Î ¼³Á¤ÇÑ´Ù. EOF¸é PEAR_Error °³Ã¼°¡ ¸®ÅϵǸç, OK(DB_OK »ó¼ö)¸é 1ÀÌ ¸®ÅϵȴÙ. ¸¸¾à PEAR°¡ Á¤ÀǵǾî ÀÖÁö ¾ÊÀº °æ¿ì EOF½Ã °ÅÁþÀÌ ¸®ÅϵȴÙ. FetchInto( )´Â ³»ºÎÀûÀ¸·Î ÇöÀç ÇàÀ» ¸®ÅÏÇÑ ÈÄ, ´ÙÀ½ ·¹ÄÚµå·Î À̵¿ÇÑ´Ù.

FetchRow()°¡ »ç¿ëÇϱ⠽±´Ù. À§¸¦ ÂüÁ¶ÇÑ´Ù.

FetchField($column_number)

¿¬°üµÈ ÇʵåÀÇ name, type¿Í max_length Æ÷ÇÔÇÏ´Â °³Ã¼¸¦ ¸®ÅÏÇÑ´Ù. ¸¸¾à max_length¸¦ ½Å·Ú¼ºÀÖ´Â ¹æ¹ýÀ¸·Î °áÁ¤ÇÒ ¼ö ¾øÀ¸¸é -1ÀÌ ¸®ÅϵȴÙ. Ä÷³ ¹øÈ£´Â 0ºÎÅÍ ½ÃÀ۵ȴÙ. ÂüÁ¶: ¿¹ 2.

FieldCount( )

·¹ÄÚµå¼Â¿¡¼­ Çʵå(Ä÷³)ÀÇ ¼ö¸¦ ¸®ÅÏÇÑ´Ù.

RecordCount( )

·¹ÄÚµå¼ÂÀÇ Çà¼ö¸¦ ¸®ÅÏÇÑ´Ù. ¸®ÅϵǴ Çà¼ö¸¦ µ¥ÀÌŸº£À̽º µå¶óÀ̹ö API·ÎºÎÅÍ °áÁ¤ÇÒ ¼ö ¾øÀ¸¸é ¸ðµç ÇàÀ» ¹öÆÛ¸µÇÏ°í ¸ðµç ·¹Äڵ尡 º¹¿øµÈ ÈÄ Çà¼ö¸¦ °è»êÇؼ­ ¸®ÅÏÇÑ´Ù. ÀÌ ¹öÆÛ¸µÀº Àü¿ª º¯¼ö $ADODB_COUNTRECS¸¦ °ÅÁþÀ¸·Î ¼³Á¤ÇÔÀ¸·Î¼­ »ç¿ëÇÏÁö ¾ÊÀ» ¼ö ÀÖ´Ù(¼º´É¶§¹®¿¡). $ADODB_COUNTRECS¸¦ °ÅÁþÀ¸·Î ¼³Á¤Çϸé RecordCount( )´Â ¸î¸î µ¥ÀÌŸº£À̽º¿¡¼­ -1À» ¸®ÅÏÇÒ °ÍÀÌ´Ù. Áö¿øµÇ´Â µ¥ÀÌŸº£À̽º ¸ñ·ÏÀº À§¸¦ ÂüÁ¶Çϱ⠹ٶõ´Ù.

RowCount´Â RecordCountÀÇ µ¿ÀǾîÀÌ´Ù.

PO_RecordCount($table, $where)

·¹ÄÚµå¼ÂÀÇ Çà¼ö¸¦ ¸®ÅÏÇÑ´Ù. µ¥ÀÌŸº£À̽º°¡ ÀÌ ±â´ÉÀ» Áö¿øÇÏÁö¾Ê´Â °æ¿ì $table Å×ÀÌºí¿¡´ëÇØ ÁÖ¾îÁø $where Á¶°ÇÀ¸·Î SELECT COUNT(*)¸¦ ¼öÇàÇÏ°í Æò°¡µÈ ·¹ÄÚµå Å©±â¸¦ ¸®ÅÏÇÑ´Ù.

$numrows = $rs->PO_RecordCount("articles_table", "group=$group");

NextRecordSet()

ÇϳªÀÇ ÁúÀÇ¿¡ ¿©·¯ °³ÀÇ ·¹ÄÚµå¼ÂÀ» ¸®ÅÏÇÏ´Â µ¥ÀÌŸº£À̽ºÀÇ °æ¿ì ÀÌ ÇÔ¼ö¸¦ ÀÌ¿ëÇؼ­ ´ÙÀ½ ·¹ÄÚµå¼ÂÀ¸·Î ÀüȯÇÒ ¼ö ÀÖµð. ÇöÀç mssql µå¶óÀ̹ö¸¸ Áö¿øµÈ´Ù.

$rs = $db->Execute('execute return_multiple_rs');
$arr1 = $rs->GetArray();
$rs->NextRecordSet();
$arr2 = $rs->GetArray();

FetchObject($toupper=true)

ÇöÀç ÇàÀ» °³Ã¼·Î¼­ ¸®ÅÏÇÑ´Ù. ¸¸¾à $toupper¸¦ ÂüÀ¸·Î ¼³Á¤ÇÏ¸é °³Ã¼ Çʵå´Â ´ë¹®ÀÚ·Î ¼³Á¤µÈ´Ù. ÁÖÀÇ: ÇàÀ» °³Ã¼·Î¼­ Á¢±ÙÇÒ ¶§ »õ·Î¿î ÇÔ¼ö, FetchNextObject()¸¦ »ç¿ëÇÒ °ÍÀ» ±Ç°íÇÑ´Ù. ¾Æ·¡¸¦ ÂüÁ¶Çϱ⠹ٶõ´Ù.

FetchNextObject($toupper=true)

ÇöÀçÇàÀ» °³Ã¼·Î¼­ °¡Á®¿À°í ÀÚµ¿ÀûÀ¸·Î ´ÙÀ½ ÇàÀ¸·Î À̵¿ÇÑ´Ù. EOFÀÇ °æ¿ì °ÅÁþÀÌ ¸®ÅϵȴÙ. $toupperÀ» ÂüÀ¸·Î ¼³Á¤ÇÏ¸é °³Ã¼ Çʵå´Â ´ë¹®ÀÚ·Î ¼³Á¤µÈ´Ù.

$rs = $db->Execute('select firstname,lastname from table');
if ($rs) {
	while ($o = $rs->FetchNextObject()) {
		print "$o->FIRSTNAME, $o->LASTNAME<BR>";
	}
}

FetchNextObject()¸¦ »ç¿ëÇÏ¸é ¼Óµµ¸é¿¡¼­ ¸î¸î ±³È¯Á¡ÀÌ ¹ß»ýÇÑ´Ù. ¼º´ÉÀÌ Áß¿äÇÏ´Ù¸é fields[] ¹è¿­·Î ÇàÀ» Á¢±ÙÇØ¾ß ÇÑ´Ù.

FetchObj()

ÇöÀç ·¹Äڵ带 °³Ã¼·Î¼­ ¸®ÅÏÇÑ´Ù. Çʵå´Â FetchObject¿Í´Â ´Þ¸® ´ë¹®ÀÚ·Î ¹Ù²Ü ¼ö ¾ø´Ù.

FetchNextObj()

ÇöÀç ·¹Äڵ带 °³Ã¼·Î¼­ ¸®ÅÏÇÏ°í ´ÙÀ½ ·¹ÄÚµå·Î À̵¿ÇÑ´Ù. ¸¸¾à EOF¸é °ÅÁþÀÌ ¸®ÅϵȴÙ. Çʵå´Â FetctNextObject¿Í´Â ´Þ¸® ´ë¹®ÀÚ·Î ¹Ù²Ü ¼ö ¾ø´Ù.

CurrentRow( )

·¹ÄÚµå¼ÂÀÇ ÇöÀç ÇàÀ» ¸®ÅÏÇÑ´Ù. 0Àº ùÇàÀÌ´Ù

AbsolutePosition( )

ADO¿ÍÀÇ È£È¯¼º ¶§¹®¿¡ »ç¿ëµÇ´Â ÇÔ¼ö·Î CurrentRow¿Í µ¿ÀǾîÀÌ´Ù. ·¹ÄÚµå¼ÂÀÇ ÇöÀç ÇàÀ» ¸®ÅÏÇÑ´Ù. 0Àº ù¹ø° ÇàÀÌ´Ù.

MetaType($nativeDBType[,$field_max_length],[$fieldobj])

¹®ÀÚ¿­·Î ÁÖ¾îÁø DB °íÀ¯ÀÇ ÇʵåÇü $nativeDBType°ú ÇÊµå ±æÀÌ $field_max_length·Î ÀÏ¹Ý ¸ÞŸ ÇüÀ» °áÁ¤ÇÑ´Ù. ÁÖÀÇ: ÇÊµå ±æÀ̸¦ ¾Ë ¼ö ¾ø´Â °æ¿ì field_max_length´Â -1ÀÌµÉ ¼ö ÀÖ´Ù. FetchField()¿¡ÀÇÇØ ¸®ÅÏµÈ ÇÊµå °³Ã¼´Â $fieldobj³ª ù¹ø° ¸Å°³º¯¼ö $nativeDBType·Î¼­ Àü´ÞµÉ ¼ö ÀÖ´Ù. ÀÌ °ÍÀº ÇÊµå °³Ã¼¿¡ primary_key¿Í °°Àº Ãß°¡ÀûÀÎ Á¤º¸¸¦ °¡Áö°í ÀÖ´Â mysql°ú°°Àº µ¥ÀÌŸº£À̽ºÀÇ °æ¿ì À¯¿ëÇÏ´Ù.

Çʵå blobSize¸¦ »ç¿ëÇÏ°í ¹®ÀÚ Çʵ尡 ½ÇÁ¦ BlobÀÎÁö °áÁ¤ÇϱâÀ§ÇØ $field_max_length°ú ºñ±³ÇÑ´Ù. ¿¹¸¦µé¾î $db->MetaType('char')´Â 'C'¸¦ ¸®ÅÏÇÒ °ÍÀÌ´Ù

¸®ÅÏ°ª:

  • C: <input type="text"> ű׿¡¼­ º¸¿©Áö´Â ¹®ÀÚ Çʵå.
  • X: Clob(Character Large Objects) ³ª <textarea> ű׿¡¼­ º¼ ¼ö ÀÖ´Â ÅؽºÆ® Çʵå
  • D: ³¯Â¥ Çʵå
  • T: ŸÀÓ½ºÅÆÇÁ Çʵå
  • L: ³í¸® Çʵå(ºÎ¿ï ¶Ç´Â ºñÆ® Çʵå)
  • N: ¼ýÀÚ Çʵå. 10Áø¼ö, ¼ýÀÚ, ºÎµ¿ ¼Ò¼ýÁ¡, ½Ç¼ö¸¦ Æ÷ÇÔÇÑ´Ù.
  • I: Á¤¼ö Çʵå.
  • R: Ä«¿îÅͳª ÀÚµ¿ Áõ°¡ Çʵå. ¼ýÀÚÇü À̾î¾ß ÇÑ´Ù.
  • B: Blob(Binary Large Objects.)

ADOdb 3.0 ÀÌ»ó ¹öÀü¿¡¼­ MetaType´Â ù¹ø° ¸Å°³º¯¼ö·Î $nativeDBType ´ë½Å¿¡ $fieldobj¸¦ ÃëÇÑ´Ù.

Close( )

·¹ÄÚµå¼ÂÀ» ´Ý´Â´Ù.


function rs2html($adorecordset,[$tableheader_attributes], [$col_titles])

ÀÌ ÇÔ¼ö´Â PHPÀÇ odbc_result_all°ú À¯»çÇÑ ´Üµ¶ ÇÔ¼ö(rs2html = ·¹ÄÚµå¼ÂÀ» HTML Å×À̺í·Î º¯È¯)·Î¼­ ADORecordSet, $adorecordsetÀ» HTML Ç¥·Î Ãâ·ÂÇÑ´Ù. $tableheader_attributesÀ¸·Î Å×À̺íÀÇ cellpadding, cellspacing¿Í border ¼Ó¼ºÀ» Á¦¾îÇÒ ¼ö ÀÖ´Ù. ¸¶Áö¸·À¸·Î µ¥ÀÌŸº£À̽º Ä÷³¸íÀº ¹è¿­ $col_titlesÀ¸·Î º¯°æÇÒ ¼ö ÀÖ´Ù. ÀÌ ÇÔ¼ö´Â ·¹ÄÚµå¼ÂÀ» Ç¥·Î Ãâ·ÂÇϱâÀ§ÇØ ¼³°èµÈ °ÍÀÌ ¾Æ´Ï¶ó µð¹ö±ëÀ» º¸´Ù½±°ÔÇϱâ À§ÇØ ¼³°èµÈ °ÍÀÌ´Ù.

ÀÌ ÇÔ¼ö¸¦ »ç¿ëÇϱâÀü¿¡ tohtml.inc.php¸¦ Include ÇÒ ÇÊ¿ä°¡ ÀÖ´Ù.

rs2htmlÀÇ ¿¹:

<?
include('tohtml.inc.php'); # ADOdb °øÅë ÄÚµå Àбâ
include('adodb.inc.php'); # ADOdb °øÅë ÄÚµå Àбâ
$conn = &ADONewConnection('mysql');   # Á¢¼Ó »ý¼º 
$conn->PConnect('localhost','userid','','agora');# MySQL, agora db¿¡ ¿¬°á
$sql = 'select CustomerName, CustomerID from customers'; 
$rs   = $conn->Execute($sql); 
rs2html($rs,'border=2 cellpadding=3',array('Customer Name','Customer ID'));
?>

ADOdb ¶óÀ̺귯¸®¿Í Microsoft ADO¿ÍÀÇ Â÷ÀÌ

  1. ADOdb´Â Á¢¼Ó °³Ã¼¿¡ÀÇÇØ »ý¼ºµÈ ·¹ÄÚµå ¼Â¸¸ Áö¿øÇÑ´Ù. ·¹ÄÚµå¼ÂÀº µ¶¸³ÀûÀ¸·Î »ý¼ºÇÒ ¼ö ¾ø´Ù.
  2. ADO ¼Ó¼ºÀº ADOdb¿¡¼­ ÇÔ¼ö·Î¼­ ±¸ÇöµÇ¾ú´Ù. ÀÌ °ÍÀº ¹Ì·¡¿¡ º¸°­µÉ ADO ±â´É º¸´Ù ½±°Ô ±¸ÇöÇÒ ¼ö ÀÖµµ·Ï ÇØÁØ´Ù.
  3. ADOdbÀÇ ADORecordSet->Move()´Â »ó´ë À§Ä¡°¡ ¾Æ´Ï¶ó Àý´ë À§Ä¡¸¦ »ç¿ëÇÑ´Ù. ¾Æ¿ï·¯ Ã¥°¥ÇÇ´Â Áö¿øÇÏÁö¾Ê´Â´Ù.
  4. ADORecordSet->AbsolutePosition() Àº ·¹ÄÚ¼ÂÀ» À̵¿Çϴµ¥ »ç¿ëÇÒ ¼ö ¾ø´Ù.
  5. ADO ¸Å°³º¯¼ö °³Ã¼´Â Áö¿øµÇÁö¾Ê´Â´Ù. ´ë½Å¿¡ ADOConnection::Parameter( ) ÇÔ¼ö¸¦ °¡Áö°í ÀÖ´Ù. ÀÌ ÇÔ¼ö´Â ¸Å°³º¯¼ö¸¦ Áغñ(ÄÄÆÄÀÏ)ÇÏ°í, ÀúÀåµÈ ÇÁ·Î½ÃÀú¸¦ È£ÃâÇÒ ¼ö ÀÖ´Â °£´ÜÇÑ ÀÎÅÍÆäÀ̽º¸¦ Á¦°øÇÑ´Ù.
  6. ·¹ÄÚµå¼ÂÀ» ÆäÀÌÁöÈ­Çϴµ¥ »ç¿ëµÇ´Â ·¹ÄÚµå¼Â ¼Ó¼ºÀ» »ç¿ëÇÒ ¼ö ÀÖÁö¸¸ ¿¹ 8ó·³ ±¸ÇöµÇ¾ú´Ù.

µ¥ÀÌŸº£À̽º µå¶óÀ̹ö ±æÀâÀÌ

ÀÌ ¹®¼­´Â »õ·Î¿î µ¥ÀÌŸº£À̽º¿¡ ¿¬°áÇÏ´Â Å©·¡½º¸¦ ¾î¶»°Ô ¸¸µé¼ö ÀÖ´Â °¡¸¦ ¼³¸íÇÏ°í ÀÖ´Ù. ÀÌ¿Í°°Àº Å©·¡½º¸¦ ¸¸µé±â·Î °áÁ¤Çß´Ù¸é ÀÛ¾÷ÀÇ Áߺ¹À» ÇÇÇϱâÀ§ÇØ ¸ÕÀú ÇÊÀÚ¿¡°Ô jlim#natsoft.com.my ÁÖ¼Ò·Î ¸ÞÀÏÀ» Áֱ⠹ٶõ´Ù.

µ¥ÀÌŸº£À̽º¸¦ È£ÃâÇÏ´Â ¼Ò¹®ÀÚÀÇ µå¶óÀ̹ö¸íÀ» °áÁ¤ÇÑ´Ù. ¿¹¸¦ µé¾î xbase¶ó°í ÇÏÀÚ

adodb-xbase.inc.php ÆÄÀÏ¿¡ µÎ°³ÀÇ Å©·¡½º ADODB_xbase¿Í ADORecordSet_xbase¸¦ »ý¼ºÇÑ´Ù.

µ¥ÀÌŸº£À̽º µå¶óÀ̹öÀÇ °¡Àå °£´ÜÇÑ ÇüÅ´ ±âÁ¸ÀÇ ODBC µå¶óÀ̹ö¿¡ Àû¿ëÇÏ´Â °ÍÀÌ´Ù. ±×¸®°í »õ·Î¿î ³¯Â¥¿Í ŸÀÓ½ºÅÆÇÁ Çü½Ä, »ç¿ëµÈ ¿¬°á ¿¬»êÀÚ, Âü°ú °ÅÁþÀ» Áö¿øÇϵµ·Ï ADODB_xbase extends ADODB_odbc Å©·¡½º¸¦ »ý¼ºÇÒ ÇÊ¿ä°¡ ÀÖ´Ù. ADORecordSet_xbase extends ADORecordSet_odbc ÀÇ °æ¿ì MetaType ÇÔ¼ö¸¦ º¯°æÇÒ ÇÊ¿ä°¡ ÀÖ´Ù. ¿¹·Î¼­ adodb-vfp.inc.php¸¦ º¸±â ¹Ù¶õ´Ù.

º¸´Ù º¹ÀâÇÑ °ÍÀº »õ·Î¿î PHP È®Àå ¸ðµâ¿¡ ¿¬°áÇÏ´Â »õ·Î¿î µ¥ÀÌŸº£À̽º µå¶óÀ̹ö¸¦ ÀüºÎ °³¹ßÇÏ´Â °ÍÀÌ´Ù. ±×¸®°í ¿©·¯°¡Áö ÇÔ¼ö¸¦ ±¸ÇöÇÒ ÇÊ¿ä°¡ ÀÖ´Ù. ´ÙÇàÀÌ º¹ÀâÇÑ ´ëºÎºÐÀÇ Äڵ带 º¯°æÇÏÁö¾Ê¾Æµµ µÈ´Ù. ¸î¸î Stub ÇÔ¼ö¸¸ º¯°æÇÏ¸é µÈ´Ù. ¿¹·Î¼­ adodb-mysql.inc.php¸¦ º¸±â ¹Ù¶õ´Ù.

ADOdb¿¡¼­ ³»ºÎÀûÀ¸·Î »ç¿ëÇϱâ´Â ±âº» ³¯Â¥ Çü½ÄÀº YYYY-MM-DD (Ansi-92)ÀÌ´Ù. ¸ðµç ³¯Â¥´Â ADOdbÀÇ Date ÇÔ¼ö·Î Àü´ÞµÉ ¶§ ÀÌ Çü½ÄÀ¸·Î º¯È¯µÇ¾î¾ß ÇÑ´Ù. _pconnect _connect¿¡¼­ ALTER SESSIONÀ» »ç¿ëÇؼ­ ±âº» ³¯Â¥ Çü½ÄÀ» º¯°æÇÏ´Â ¹æ¹ýÀº OracleÀ» º¸±â ¹Ù¶õ´Ù.

ADOConnection ÇÔ¼ö Áßø

ADOConnection¿¡¼­ À¯µµµÈ ÇÔ¼ö¿¡´ëÇØ »ý¼ºÀÚ¸¦ Á¤ÀÇÇÏ´Â °ÍÀº ¿É¼ÇÀÌ´Ù. ¹Ýµå½Ã ±âº» Å©·¡½º »ý¼ºÀÚ¸¦ È£ÃâÇÒ ÇÊ¿ä´Â ¾ø´Ù

_connect: ConnectÀÇ Àú¼öÁØ ±¸Çö. Âü ¶Ç´Â °ÅÁþÀ» ¸®ÅÏ. _connectionID¸¦ ¼³Á¤ÇØ¾ß ÇÑ´Ù.

_pconnect: PconnectÀÇ Àú¼öÁØ ±¸Çö. Âü ¶Ç´Â °ÅÁþÀ» ¸®ÅÏ. _connectionID¸¦ ¼³Á¤ÇØ¾ß ÇÑ´Ù.

_query: ÁúÀÇ ½ÇÇà. queryID¸¦ ¸®ÅÏÇϰųª °ÅÁþÀ» ¸®ÅÏ.

_close: Á¢¼ÓÀ» ´ÝÀ½ -- PHP´Â ¸ðµç ·¹ÄÚµå¼ÂÀ» »èÁ¦ÇÑ´Ù.

ErrorMsg: ÇÁ¶óÀ̺ø º¯¼ö _errorMsg¿¡ ¿À·ù ¸Þ½ÃÁö ÀúÀå.

ADOConnection ÇÊµå ¼³Á¤

_bindInputArray: ÂüÀ¸·Î ¼³Á¤. SQLÀÇ Insert, Update½Ã ¸Å°³º¯¼ö ¹ÙÀεù¿¡ ?°¡ »ç¿ë(¿¹: ODBC)µÇ¸é ÂüÀ¸·Î ¼³Á¤ÇÑ´Ù.

fmtDate

fmtTimeStamp

true

false

concat_operator

replaceQuote

hasLimit MySQLÀÇ SELECT * FROM TABLE LIMIT 10 Áö¿ø.

hasTop Microsoft Çü½ÄÀÇ SELECT TOP 10 * FROM TABLE Áö¿ø.

ADORecordSet ÇÔ¼ö Áßø

ºÎ¸ð Å©·¡½º¸¦ È£ÃâÇÏ´Â ADORecordSetÀÇ À¯µµµÈ Å©·¡½º¿¡´ëÇÑ »ý¼ºÀÚ¸¦ Á¤ÀÇÇÒ ÇÊ¿ä°¡ ÀÖ´Ù.

FetchField: À§ÀÇ ADORecordSet¿¡¼­ ¼³¸íÇß´Ù

_initrs: ·¹ÄÚµå¼ÂÀÇ Àú¼öÁØ ÃʱâÈ­: _numOfRows¿Í _numOfFields Çʵ带 ¼³Á¤ÇÑ´Ù -- »ý¼ºÀÚ¿¡ÀÇÇØ È£ÃâµÈ´Ù.

_seek: ƯÁ¤ Çà °Ë»ö. ÇÊµå ¹è¿­·Î µ¥ÀÌŸ¸¦ ÀÐÁö¸¶¶ó. ÀÌ °ÍÀº _fetch¿¡ÀÇÇØ ¿Ï·áµÈ´Ù. Âü ¶Ç´Â °ÅÁþÀ» ¸®ÅÏÇÑ´Ù. ÁÖÀÇ: ¸î¸î Interbase¿Í °°Àº ¸î¸î µå¶óÀ̹ö´Â Çà °Ë»öÀ» Áö¿øÇÏÁö ¾Ê´Â´Ù. ÀÌ °æ¿ì canSeek¸¦ °ÅÁþÀ¸·Î ¼³Á¤ÇÑ´Ù.

_fetch: µ¥ÀÌŸº£À̽º È®Àå ÇÔ¼ö¸¦ »ç¿ëÇؼ­ ÇàÀ» °¡Á®¿À°í ´ÙÀ½ ÇàÀ¸·Î À̵¿ÇÑ´Ù. fields ¹è¿­À» ¼³Á¤ÇÑ´Ù. ¸Å°³º¯¼ö $ignore_fields°¡ ÂüÀ̸é fields ¹è¿­À» °¡Á®¿Ã ÇÊ¿ä´Â ¾øÀ¸¸ç ¹Ù·Î ´ÙÀ½ ÇàÀ¸·Î À̵¿ÇÑ´Ù. ±×¸®°í Âü ¶Ç´Â °ÅÁþÀ» ¸®ÅÏÇÑ´Ù.

_close: ·¹ÄÚµå¼ÂÀ» ´Ý´Â´Ù.

Fields: PHP È®Àå ¸ðµâ¿¡ÀÇÇØ ¸®ÅÏµÈ ¹è¿­ÇüÀÌ ¿¬°ü¹è¿­ÀÌ ¾Æ´Ï¸é ÀÌ °ÍÀ» ÁßøÇØ¾ß ÇÑ´Ù. ¿¹´Â adodb-odbc.inc.php¸¦ º¸±â ¹Ù¶õ´Ù. MySQL°ú MSSQL°ú °°Àº µ¥ÀÌŸº£À̽º´Â ¿¬°ü¹è¿­À» ¸®ÅÏÇÑ´Ù. µû¶ó¼­ ÀÌ ÇÔ¼ö¸¦ Áßø½Ãų ÇÊ¿ä´Â ¾ø´Ù.

ADOConnection ÇÊµå ¼³Á¤

canSeek: _seek ÇÔ¼ö°¡ µ¿ÀÛÇϸé ÂüÀ¸·Î¼­ ¼³Á¤.

ÇÒÀÏ:

°³¹ß ¿¹Á¤Ç¥ ±â»ç¸¦ º»´Ù.

HTTP ¿ø°Ý ÇÔ¼ö È£ÃâÀ» »ç¿ëÇؼ­ À©µµ¿ì¿Í À¯´Ð½º µ¥ÀÌŸº£À̽º »çÀ̸¦ ¿¬°áÇÏ´Â ÀÛ¾÷À» ¼öÇàÁßÀÎ ADOdb ÇÁ·Ï½Ã ±â»ç¸¦ º»´Ù. µ¥ÀÌŸº£À̽º¿¡´ëÇÑ Á¤º¸´Â palslib.com¸¦ ¹æ¹®ÇÏ°í PHP ÃÖÀûÈ­¿¡´ëÇÑ ±â»ç¸¦ Àб⠹ٶõ´Ù.

º¯°æ »çÇ×

4.05 ? ? 2003

Datadict did not handle types like 16.0 properly in _GetSize. Fixed.

Oci8 driver SelectLimit() bug &= instead of =& used. Thx to Swen Th?mler.

Jesse Mullan suggested not flushing outp when output buffering enabled. Due to Apache 2.0 bug. Added.

MetaTables/MetaColumns return ref bug with PHP5 fixed in adodb-datadict.inc.php.

New mysqli driver contributed by Arjen de Rijke. Based on adodb 3.40 driver. John added BeginTrans, CommitTrans, RollbackTrans, IfNull, SQLDate. Also fixed return ref bug.

4.04 13 Nov 2003

Switched back to foreach - faster than list-each.

Fixed bug in ado driver - wiping out $this->fields with date fields.

Performance Monitor, View SQL, Explain Plan did not work if strlen($SQL)>max($_GET length). Fixed.

Performance monitor, oci8 driver added memory sort ratio.

Added random property, returns SQL to generate a floating point number between 0 and 1;

4.03 6 Nov 2003

The path to adodb-php4.inc.php and adodb-iterators.inc.php was not setup properly.

Patched SQLDate in interbase to support hours/mins/secs. Thx to ari kuorikoski.

Force autorollback for pgsql persistent connections - apparently pgsql did not autorollback properly before 4.3.4. See http://bugs.php.net/bug.php?id=25404

4.02 5 Nov 2003

Some errors in adodb_error_pg() fixed. Thx to Styve.

Spurious Insert_ID() error was generated by LogSQL(). Fixed.

Insert_ID was interfering with Affected_Rows() and Replace() when LogSQL() enabled. Fixed.

More foreach loops optimized with list/each.

Null dates not handled properly in ADO driver (it becomes 31 Dec 1969!).

Heinz Hombergs contributed patches for mysql MetaColumns - adding scale, made interbase MetaColumns work with firebird/interbase, and added lang/adodb-de.inc.php.

Added INFORMIXSERVER environment variable.

Added $ADODB_ANSI_PADDING_OFF for interbase/firebird.

PHP 5 beta 2 compat check. Foreach (Iterator) support. Exceptions support.

4.01 23 Oct 2003

Fixed bug in rs2html(), tohtml.inc.php, that generated blank table cells.

Fixed insert_id() incorrectly generated when logsql() enabled.

Modified PostgreSQL _fixblobs to use list/each instead of foreach.

Informix ErrorNo() implemented correctly.

Modified several places to use list/each, including GetRowAssoc().

Added UserTimeStamp() to connection class.

Added $ADODB_ANSI_PADDING_OFF for oci8po.

4.00 20 Oct 2003

Upgraded adodb-xmlschema to 1 Oct 2003 snapshot.

Fix to rs2html warning message. Thx to Filo.

Fix for odbc_mssql/mssql SQLDate(), hours was wrong.

Added MetaColumns and MetaPrimaryKeys for sybase. Thx to Chris Phillipson.

Added autoquoting to datadict for MySQL and PostgreSQL. Suggestion by Karsten Dambekalns

3.94 11 Oct 2003

Create trigger in datadict-oci8.inc.php did not work, because all cr/lf's must be removed.

ErrorMsg()/ErrorNo() did not work for many databases when logging enabled. Fixed.

Removed global variable $ADODB_LOGSQL as it does not work properly with multiple connections.

Added SQLDate support for sybase. Thx to Chris Phillipson

Postgresql checking of pgsql resultset resource was incorrect. Fix by Bharat Mediratta bharat#menalto.com. Same patch applied to _insertid and _affectedrows for adodb-postgres64.inc.php.

Added support for NConnect for postgresql.

Added Sybase data dict support. Thx to Chris Phillipson

Extensive improvements in $perf->UI(), eg. Explain now opens in new window, we show scripts which call sql, etc.

Perf Monitor UI works with magic quotes enabled.

rsPrefix was declared twice. Removed.

Oci8 stored procedure support, eg. "begin func(); end;" was incorrect in _query. Fixed.

Tiraboschi Massimiliano contributed italian language file.

Fernando Ortiz, fortiz#lacorona.com.mx, contributed informix performance monitor.

Added _varchar (varchar arrays) support for postgresql. Reported by PREVOT St?hane.

3.92 22 Sept 2003

Added GetAssoc and CacheGetAssoc to connection object.

Removed TextMax and CharMax functions from adodb.inc.php.

HasFailedTrans() returned false when trans failed. Fixed.

Moved perf driver classes into adodb/perf/*.php.

Misc improvements to performance monitoring, including UI().

RETVAL in mssql Parameter(), we do not append @ now.

Added Param($name) to connection class, returns '?' or ":$name", for defining bind parameters portably.

LogSQL traps affected_rows() and saves its value properly now. Also fixed oci8 _stmt and _affectedrows() bugs.

Session code timestamp check for oci8 works now. Formerly default NLS_DATE_FORMAT stripped off time portion. Thx to Tony Blair (tonanbarbarian#hotmail.com). Also added new $conn->datetime field to oci8, controls whether MetaType() returns 'D' ($this->datetime==false) or 'T' ($this->datetime == true) for DATE type.

Fixed bugs in adodb-cryptsession.inc.php and adodb-session-clob.inc.php.

Fixed misc bugs in adodb_key_exists, GetInsertSQL() and GetUpdateSQL().

Tuned include_once handling to reduce file-system checking overhead.

3.91 9 Sept 2003

Only released to InterAkt

Added LogSQL() for sql logging and $ADODB_NEWCONNECTION to override factory for driver instantiation.

Added IfNull($field,$ifNull) function, thx to johnwilk#juno.com

Added portable substr support.

Now rs2html() has new parameter, $echo. Set to false to return $html instead of echoing it.

3.90 5 Sept 2003

First beta of performance monitoring released.

MySQL supports MetaTable() masking.

Fixed key_exists() bug in adodb-lib.inc.php

Added sp_executesql Prepare() support to mssql.

Added bind support to db2.

Added swedish language file - Christian Tiberg" christian#commsoft.nu

Bug in drop index for mssql data dict fixed. Thx to Gert-Rainer Bitterlich.

Left join setting for oci8 was wrong. Thx to johnwilk#juno.com

3.80 27 Aug 2003

Patch for PHP 4.3.3 cached recordset csv2rs() fread loop incompatibility.

Added matching mask for MetaTables. Only for oci8, mssql and postgres currently.

Rewrite of "oracle" driver connection code, merging with "oci8", by Gaetano.

Added better debugging for Smart Transactions.

Postgres DBTimeStamp() was wrongly using TO_DATE. Changed to TO_TIMESTAMP.

ADODB_FETCH_CASE check pushed to ADONewConnection to allow people to define it after including adodb.inc.php.

Added portugese (brazilian) to languages. Thx to "Levi Fukumori".

Removed arg3 parameter from Execute/SelectLimit/Cache* functions.

Execute() now accepts 2-d array as $inputarray. Also changed docs of fnExecute() to note change in sql query counting with 2-d arrays.

Added MONEY to MetaType in PostgreSQL.

Added more debugging output to CacheFlush().

3.72 9 Aug 2003

Added qmagic($str), which is a qstr($str) that auto-checks for magic quotes and does the right thing...

Fixed CacheFlush() bug - Thx to martin#gmx.de

Walt Boring contributed MetaForeignKeys for postgres7.

_fetch() called _BlobDecode() wrongly in interbase. Fixed.

adodb_time bug fixed with dates after 2038 fixed by Jason Pell. http://phplens.com/lens/lensforum/msgs.php?id=6980

3.71 4 Aug 2003

The oci8 driver, MetaPrimaryKeys() did not check the owner correctly when $owner == false.

Russian language file contributed by "Cyrill Malevanov" cyrill#malevanov.spb.ru.

Spanish language file contributed by "Horacio Degiorgi" horaciod#codigophp.com.

Error handling in oci8 bugfix - if there was an error in Execute(), then when calling ErrorNo() and/or ErrorMsg(), the 1st call would return the error, but the 2nd call would return no error.

Error handling in odbc bugfix. ODBC would always return the last error, even if it happened 5 queries ago. Now we reset the errormsg to '' and errorno to 0 everytime before CacheExecute() and Execute().

3.70 29 July 2003

Added new SQLite driver. Tested on PHP 4.3 and PHP 5.

Added limited "sapdb" driver support - mainly date support.

The oci8 driver did not identify NUMBER with no defined precision correctly.

Added ADODB_FORCE_NULLS, if set, then PHP nulls are converted to SQL nulls in GetInsertSQL/GetUpdateSQL.

DBDate() and DBTimeStamp() format for postgresql had problems. Fixed.

Added tableoptions to ChangeTableSQL(). Thx to Mike Benoit.

Added charset support to postgresql. Thx to Julian Tarkhanov.

Changed OS check for MS-Windows to prevent confusion with darWIN (MacOS)

Timestamp format for db2 was wrong. Changed to yyyy-mm-dd-hh.mm.ss.nnnnnn.

adodb-cryptsession.php includes wrong. Fixed.

Added MetaForeignKeys(). Supported by mssql, odbc_mssql and oci8.

Fixed some oci8 MetaColumns/MetaPrimaryKeys bugs. Thx to Walt Boring.

adodb_getcount() did not init qryRecs to 0. Missing "WHERE" clause checking in GetUpdateSQL fixed. Thx to Sebastiaan van Stijn.

Added support for only 'VIEWS' and "TABLES" in MetaTables. From Walt Boring.

Upgraded to adodb-xmlschema.inc.php 0.0.2.

NConnect for mysql now returns value. Thx to Dennis Verspuij.

ADODB_FETCH_BOTH support added to interbase/firebird.

Czech language file contributed by Kamil Jakubovic jake#host.sk.

PostgreSQL BlobDecode did not use _connectionID properly. Thx to Juraj Chlebec.

Added some new initialization stuff for Informix. Thx to "Andrea Pinnisi" pinnisi#sysnet.it

ADODB_ASSOC_CASE constant wrong in sybase _fetch(). Fixed.

3.60 16 June 2003

We now SET CONCAT_NULL_YIELDS_NULL OFF for odbc_mssql driver to be compat with mssql driver.

The property $emptyDate missing from connection class. Also changed 1903 to constant (TIMESTAMP_FIRST_YEAR=100). Thx to Sebastiaan van Stijn.

ADOdb speedup optimization - we now return all arrays by reference.

Now DBDate() and DBTimeStamp() now accepts the string 'null' as a parameter. Suggested by vincent.

Added GetArray() to connection class.

Added not_null check in informix metacolumns().

Connection parameters for postgresql did not work correctly when port was defined.

DB2 is now a tested driver, making adodb 100% compatible. Extensive changes to odbc driver for DB2, including implementing serverinfo() and SQLDate(), switching to SQL_CUR_USE_ODBC as the cursor mode, and lastAffectedRows and SelectLimit() fixes.

The odbc driver's FetchField() field names did not obey ADODB_ASSOC_CASE. Fixed.

Some bugs in adodb_backtrace() fixed.

Added "INT IDENTITY" type to adorecordset::MetaType() to support odbc_mssql properly.

MetaColumns() for oci8, mssql, odbc revised to support scale. Also minor revisions to odbc MetaColumns() for vfp and db2 compat.

Added unsigned support to mysql datadict class. Thx to iamsure.

Infinite loop in mssql MoveNext() fixed when ADODB_FETCH_ASSOC used. Thx to Josh R, Night_Wulfe#hotmail.com.

ChangeTableSQL contributed by Florian Buzin.

The odbc_mssql driver now sets CONCAT_NULL_YIELDS_NULL OFF for compat with mssql driver.


0.10 Sept 9 2000 First release

Old changelog history moved to old-changelog.htm.